Skip to content

Instantly share code, notes, and snippets.

@emopers
emopers / testng
Last active December 28, 2015 01:08
rand_col_sync_111
Title:
FailedReporter does not synchronize iteration on a synchronized map
Body:
In FailedReporter.java:63, the synchronized map, results,
is iterated over in an unsynchronized manner, but according to the [Oracle Java 7 API specification](http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#synchronizedMap%28java.util.Map%29),
this is not thread-safe and can lead to non-deterministic behavior.
This pull request adds a fix by synchronizing the iteration on results.
@emopers
emopers / commons-validator
Created December 27, 2015 10:34
rand_col_sync_71
Title:
Field does not synchronize iteration on synchronized list
Body:
In Field.java:908, the synchronized list `dependencyList` is iterated
in an unsynchronized manner,
but according to the [Oracle Java 7 API specification](http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#synchronizedList(java.util.List)),
this is not thread-safe and can lead to non-deterministic behavior.
This pull request adds a fix by synchronizing the iteration.
@emopers
emopers / testng
Last active December 27, 2015 07:58
randoop_col_sync_114
Title:
XMLReporter does not synchronize iteration on a synchronized map
Body:
In XMLReporter.java:46, the synchronized map returned by getResults method
is iterated over in an unsynchronized manner, but according to the [Oracle Java 7 API specification](http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#synchronizedMap%28java.util.Map%29),
this is not thread-safe and can lead to non-deterministic behavior.
This pull request adds a fix by synchronizing the iteration.
@emopers
emopers / testng
Created December 27, 2015 07:28
randoop_col_sync_113
Title:
SuiteHTMLReporter does not synchronize iteration on a synchronized map
Body:
In SuiteHTMLReporter.java:575, the synchronized map, suiteResults,
is iterated over in an unsynchronized manner, but according to the [Oracle Java 7 API specification](http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#synchronizedMap%28java.util.Map%29),
this is not thread-safe and can lead to non-deterministic behavior.
This pull request adds a fix by synchronizing the iteration on suiteResults.
@emopers
emopers / testng
Last active December 27, 2015 07:00
randoop_col_sync_112
Title:
SuiteHTMLReporter does not synchronize iteration on a synchronized map
Body:
In SuiteHTMLReporter.java:575, the synchronized map, suiteResults,
is iterated over in an unsynchronized manner, but according to the [Oracle Java 7 API specification](http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#synchronizedMap%28java.util.Map%29),
this is not thread-safe and can lead to non-deterministic behavior.
This pull request adds a fix by synchronizing the iteration on suiteResults.
@emopers
emopers / Joda-time 36 boas
Last active December 27, 2015 13:36
boas
Title:
Closing ObjectOutputStream before calling toByteArray on the underlying ByteArrayOutputStream
Subject:
When an ObjectOutputStream instance wraps an underlying ByteArrayOutputStream instance,
it is recommended to flush or close the ObjectOutputStream before invoking the underlying instances's toByteArray().
Although in these cases this is not strictly necessary because the
writeObject method is invoked right before toByteArray, and writeObject
internally calls flush/drain. However, it is a good practice to call
flush/close explicitly as mentioned for example (here)
[http://stackoverflow.com/questions/2984538/how-to-use-bytearrayoutputstream-and-dataoutputstream-simultaneously-java]
@emopers
emopers / No. 39 randoop
Created December 22, 2015 23:11
jboss-websockets
Title: Hybi00Handshake does not catch NumberFormatException
Body:
Hybi00Handshake.java calls `java.lang.long.parseLong` without first
checking whether the argument parses. This
lead to an uncaught `NumberFormateException`: [Oracle Java 7 API specification](http://docs.oracle.com/javase/7/docs/api/java/lang/Long.html#parseLong%28java.lang.String,%20int%29).
This pull request adds a check and a test for this issue.
@emopers
emopers / ByteArrayOutputStream_FlushBeforeRetrieve
Last active December 23, 2015 20:46
JavaMop_bogus_property_3
**NOTE to myself** I am only looking at output streams that are relevant to our violations.
** NOT TOO Specific **
ByteArrayOutputStream_FlushBeforeRetrieve property [here](http://bit.ly/1S6ZLih) checks that if OutputStream (or its subclass)
instance is built on top of an
underlying ByteArrayOutputStream instance, it should call flush or close methods before the underlying instance's toByteArray() is invoked.
Note that flush and close methods of both OutputStream and ByteArrayOutputStream has no effect according to [Javadoc7](http://bit.ly/1QDICO9 ).
There are two issues with this property:
First this property does not exist in Javadoc 6 or 7 or 8
Second, some of the OutputStream flush and close methods are Nop. So calling them has no effect. Following are the
@emopers
emopers / HttpURLConnection_SetBeforeConnect
Last active March 4, 2016 20:38
JavaMop_bogus_property_2
## Unneccessary property ##
HttpURLConnection_SetBeforeConnect property [here](http://bit.ly/1MsSrGw) warns if setFixedLengthStreamingMode(), setChunkedStreamingMode() or setRequestMethod()
are invoked after the URLConnection was made.
But there is no documentation that says that setRequestMethod() should be called before conneciton is made.
Only documentation for setFixedLengthStreamingMode() and setChunkedStreamingMode() exists.
@emopers
emopers / Iterator_RemoveOnce
Created December 22, 2015 05:20
JavaMop_bogus_property_2
## Improvement in property ##
Iterator_RemoveOnce property [here](http://bit.ly/1MsOIc7) checks for Iterator.remove() is not preceded by next() and
warns if this not is case.
In cases, where iteration is in backward fashion like in the following code snippet
if(Iterator.hasPrevious){
Iterator.previous();
Iterator.remove();
}
warning generated by Javamp will be false alarm.