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 Apr 14, 2018
1 parent 0c6c663 commit ce090a3
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 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 @@ -1704,7 +1704,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
2 changes: 2 additions & 0 deletions src/org/exist/storage/BrokerPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,8 @@ public DBBroker get(final Optional<Subject> subject) throws EXistException {
LOG.debug("Db instance is in service mode. Waiting for db to become available again ...");
wait();
} 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 @@ -1154,7 +1154,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 @@ -1168,7 +1168,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 @@ -1182,7 +1182,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 @@ -1195,7 +1195,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
7 changes: 4 additions & 3 deletions src/org/exist/storage/journal/FileSyncThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
*/
package org.exist.storage.journal;

import net.jcip.annotations.GuardedBy;

import java.io.IOException;
import java.nio.channels.FileChannel;

Expand All @@ -36,12 +38,11 @@
*/
public class FileSyncThread extends Thread {

// guarded by latch
private FileChannel endOfLog;
@GuardedBy("latch") private FileChannel endOfLog;
private final Object latch;

// guarded by this
private boolean syncTriggered = false;
@GuardedBy("this") private boolean syncTriggered = false;

// used as termination flag, volatile semantics are sufficient
private volatile boolean shutdown = 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 @@ -210,7 +210,7 @@ public boolean acquire(final LockMode mode) throws LockException {

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

@Override
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
3 changes: 1 addition & 2 deletions src/org/exist/storage/txn/Checkpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public class Checkpoint extends AbstractLoggable {
private long timestamp;
private long storedLsn;

private final DateFormat df =
DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
private final DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);

public Checkpoint(final long transactionId) {
this(null, transactionId);
Expand Down

0 comments on commit ce090a3

Please sign in to comment.