-
Notifications
You must be signed in to change notification settings - Fork 656
Improvements #1057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Improvements #1057
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,9 +69,8 @@ public class FileLog extends AbstractLog { | |
eventFileName = prefix + "event.log"; | ||
|
||
File directory = new File(messagesFileName).getParentFile(); | ||
if (!directory.exists()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. redundant check as |
||
directory.mkdirs(); | ||
} | ||
directory.mkdirs(); | ||
|
||
|
||
this.includeMillis = includeMillis; | ||
this.includeTimestampForMessages = includeTimestampForMessages; | ||
|
@@ -94,7 +93,7 @@ protected void logOutgoing(String message) { | |
|
||
private void writeMessage(FileOutputStream stream, Object lock, String message, boolean forceTimestamp) { | ||
try { | ||
synchronized(lock) { | ||
synchronized (lock) { | ||
if (forceTimestamp || includeTimestampForMessages) { | ||
writeTimeStamp(stream); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ public class MessageCracker { | |
public @interface Handler { | ||
} | ||
|
||
public class RedundantHandlerException extends RuntimeException { | ||
public static class RedundantHandlerException extends RuntimeException { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. non-static inner class will unnecessarily carry a reference to the outer class |
||
private final Class<?> messageClass; | ||
private final Method originalMethod; | ||
private final Method redundantMethod; | ||
|
@@ -55,7 +55,7 @@ public RedundantHandlerException(Class<?> messageClass, Method originalMethod, | |
|
||
@Override | ||
public String toString() { | ||
return "Duplicate handler method for " + messageClass + ", orginal method is " | ||
return "Duplicate handler method for " + messageClass + ", original method is " | ||
+ originalMethod + ", redundant method is " + redundantMethod; | ||
} | ||
} | ||
|
@@ -97,7 +97,7 @@ private boolean matchesConventionOrAnnotation(Method method) { | |
return method.getName().equals("onMessage") || method.isAnnotationPresent(Handler.class); | ||
} | ||
|
||
private class Invoker { | ||
private static class Invoker { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. non-static inner class will unnecessarily carry a reference to the outer class |
||
private final Object target; | ||
private final Method method; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -211,7 +211,7 @@ public synchronized void get(int startSequence, int endSequence, Collection<Stri | |
Cursor cursor = null; | ||
try { | ||
DatabaseEntry sequenceKey = new DatabaseEntry(); | ||
EntryBinding sequenceBinding = TupleBinding.getPrimitiveBinding(Integer.class); | ||
EntryBinding<Integer> sequenceBinding = TupleBinding.getPrimitiveBinding(Integer.class); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Making variable type safe at source instead of doing type-casting everytime it is used |
||
// Must start at start-1 because db will look for next record larger | ||
sequenceBinding.objectToEntry(startSequence - 1, sequenceKey); | ||
|
||
|
@@ -223,15 +223,15 @@ public synchronized void get(int startSequence, int endSequence, Collection<Stri | |
if (retVal == OperationStatus.NOTFOUND) { | ||
log.debug("{}/{} not matched in database {}", sequenceKey, messageBytes, messageDatabase.getDatabaseName()); | ||
} else { | ||
Integer sequenceNumber = (Integer) sequenceBinding.entryToObject(sequenceKey); | ||
Integer sequenceNumber = sequenceBinding.entryToObject(sequenceKey); | ||
while (sequenceNumber <= endSequence) { | ||
messages.add(new String(messageBytes.getData(), charsetEncoding)); | ||
if (log.isDebugEnabled()) { | ||
log.debug("Found record {}=>{} for search key/data: {}=>{}", | ||
sequenceNumber, new String(messageBytes.getData(), charsetEncoding), sequenceKey, messageBytes); | ||
} | ||
cursor.getNext(sequenceKey, messageBytes, LockMode.DEFAULT); | ||
sequenceNumber = (Integer) sequenceBinding.entryToObject(sequenceKey); | ||
sequenceNumber = sequenceBinding.entryToObject(sequenceKey); | ||
} | ||
} | ||
} catch (Exception e) { | ||
|
@@ -309,7 +309,7 @@ public void reset() throws IOException { | |
public boolean set(int sequence, String message) throws IOException { | ||
try { | ||
DatabaseEntry sequenceKey = new DatabaseEntry(); | ||
EntryBinding sequenceBinding = TupleBinding.getPrimitiveBinding(Integer.class); | ||
EntryBinding<Integer> sequenceBinding = TupleBinding.getPrimitiveBinding(Integer.class); | ||
sequenceBinding.objectToEntry(sequence, sequenceKey); | ||
DatabaseEntry messageBytes = new DatabaseEntry(message.getBytes(CharsetSupport.getCharset())); | ||
messageDatabase.put(null, sequenceKey, messageBytes); | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed redundant auto-boxing