Skip to content

Commit

Permalink
[bugfix] Analyzed FindBugs report & fixed several SEVERE issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Nikonov authored and adamretter committed Oct 7, 2016
1 parent d0a8af8 commit 40ba0d5
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/org/exist/http/RESTServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1689,7 +1689,7 @@ private void writeResourceAs(final DocumentImpl resource, final DBBroker broker,
serializer.reset();

//setup the http context
final HttpContext httpContext = serializer.new HttpContext();
final HttpContext httpContext = new HttpContext();
final HttpRequestWrapper reqw = new HttpRequestWrapper(request, formEncoding, containerEncoding);
httpContext.setRequest(reqw);
httpContext.setSession(reqw.getSession(false));
Expand Down
5 changes: 4 additions & 1 deletion src/org/exist/storage/BrokerPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -1604,7 +1604,10 @@ public DBBroker get(final Optional<Subject> subject) throws EXistException {
try {
LOG.debug("Db instance is in service mode. Waiting for db to become available again ...");
wait();
} catch(final InterruptedException e) {
}
catch(final InterruptedException e) {
Thread.currentThread().interrupt();
LOG.error("Interrupt detected");
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/org/exist/storage/NativeValueIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ private final static class ExactMatcher implements TermMatcher {

@Override
public boolean matches(final CharSequence term) {
return term.toString().equals(expr);
return term != null && term.toString().equals(expr);
}
}

Expand All @@ -1170,7 +1170,7 @@ private final static class ContainsMatcher implements TermMatcher {

@Override
public boolean matches(final CharSequence term) {
return term.toString().contains(expr);
return term != null && term.toString().contains(expr);
}
}

Expand All @@ -1184,7 +1184,7 @@ private final static class StartsWithMatcher implements TermMatcher {

@Override
public boolean matches(final CharSequence term) {
return (term.toString().startsWith(expr));
return term != null && term.toString().startsWith(expr);
}
}

Expand All @@ -1197,7 +1197,7 @@ private final static class EndsWithMatcher implements TermMatcher {

@Override
public boolean matches(final CharSequence term) {
return term.toString().endsWith(expr);
return term != null && term.toString().endsWith(expr);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/org/exist/storage/journal/FileSyncThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class FileSyncThread extends Thread {

// guarded by latch
private FileChannel endOfLog;
private Object latch;
private final Object latch;

// guarded by this
private boolean syncTriggered = false;
Expand Down
4 changes: 2 additions & 2 deletions src/org/exist/storage/journal/Journal.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
*/
@ConfigurationClass("journal")
//TODO: conf.xml refactoring <recovery> => <recovery><journal/></recovery>
public class Journal {
public final class Journal {
/**
* Logger for this class
*/
Expand Down Expand Up @@ -167,7 +167,7 @@ public Journal(final BrokerPool pool, final Path directory) throws EXistExceptio
currentBuffer = ByteBuffer.allocateDirect(1024 * 1024);

syncThread = new FileSyncThread(latch);
syncThread.start();
syncThread.start(); //this makes us to use class as a final only - no inheritance allowed

this.syncOnCommit = pool.getConfiguration().getProperty(PROPERTY_RECOVERY_SYNC_ON_COMMIT, DEFAULT_SYNC_ON_COMMIT);
if (LOG.isDebugEnabled()) {
Expand Down
2 changes: 1 addition & 1 deletion src/org/exist/storage/lock/ReentrantReadWriteLock.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public boolean acquire(int mode) throws LockException {
}

public synchronized void wakeUp() {
notify();
notifyAll();
}

public boolean attempt(int mode) {
Expand Down
3 changes: 2 additions & 1 deletion src/org/exist/storage/serializers/Serializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ public abstract class Serializer implements XMLReader {
protected Subject user = null;

protected HttpContext httpContext = null;
public class HttpContext

public static class HttpContext
{
private RequestWrapper request = null;
private ResponseWrapper response = null;
Expand Down
12 changes: 8 additions & 4 deletions src/org/exist/storage/txn/Checkpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ public class Checkpoint extends AbstractLoggable {
private long timestamp;
private long storedLsn;

private final DateFormat df =
DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
private final static DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
private String formatDateTimeToString(Date date){
synchronized (df){
return df.format(date);
}
}

public Checkpoint(final long transactionId) {
this(null, transactionId);
Expand Down Expand Up @@ -69,11 +73,11 @@ public int getLogSize() {
}

public String getDateString() {
return df.format(new Date(timestamp));
return formatDateTimeToString(new Date(timestamp));
}

@Override
public String dump() {
return super.dump() + " - checkpoint at " + df.format(new Date(timestamp));
return super.dump() + " - checkpoint at " + formatDateTimeToString(new Date(timestamp));
}
}

0 comments on commit 40ba0d5

Please sign in to comment.