Permalink
Browse files

Changing native library to avoid Crash when releaseBuffer would send …

…null
  • Loading branch information...
1 parent a30ab23 commit ccce5d4c8f15631778d5e4d5af97c34b153f83db @clebertsuconic clebertsuconic committed with clebert suconic Nov 13, 2012
Binary file not shown.
Binary file not shown.
@@ -52,7 +52,7 @@
/** This definition needs to match Version.h on the native sources.
Or else the native module won't be loaded because of version mismatches */
- private static final int EXPECTED_NATIVE_VERSION = 31;
+ private static final int EXPECTED_NATIVE_VERSION = 51;
/** Used to determine the next writing sequence */
private final AtomicLong nextWritingSequence = new AtomicLong(0);
@@ -465,7 +465,9 @@ protected static TestSuite createAIOTestSuite(final Class<?> clazz)
else
{
// System.out goes towards JUnit report
- System.out.println("Test " + clazz.getName() + " ignored as AIO is not available");
+ System.out.println("Test " + clazz.getName() + " ignored as AIO is not available." +
+ "Add this to your java arguments if you are on a Linux system:" +
+ "\n-Djava.library.path=<project_home>/distribution/hornetq/src/main/resources/bin");
}
return suite;
@@ -173,6 +173,11 @@ JNIEXPORT void JNICALL Java_org_hornetq_core_asyncio_impl_AsynchronousFileImpl_r
JNIEXPORT void JNICALL Java_org_hornetq_core_asyncio_impl_AsynchronousFileImpl_destroyBuffer
(JNIEnv * env, jclass, jobject jbuffer)
{
+ if (jbuffer == 0)
+ {
+ throwException(env, NATIVE_ERROR_INVALID_BUFFER, "Null Buffer");
+ return;
+ }
void * buffer = env->GetDirectBufferAddress(jbuffer);
free(buffer);
}
View
@@ -3,6 +3,6 @@
// This definition needs to match org.hornetq.core.asyncio.impl.AsynchronousFileImpl.EXPECTED_NATIVE_VERSION
// Or else the native module won't be loaded because of version mismatches
-#define _VERSION_NATIVE_AIO 31
+#define _VERSION_NATIVE_AIO 51
#endif
@@ -313,6 +313,21 @@ public void onError(final int errorCode, final String errorMessage)
}
}
+ public void testReleaseNullBuffer() throws Exception
+ {
+ boolean failed = false;
+ try
+ {
+ AsynchronousFileImpl.destroyBuffer(null);
+ }
+ catch (Exception expected)
+ {
+ failed = true;
+ }
+
+ assertTrue("Exception expected", failed);
+ }
+
public void testInvalidReads() throws Exception
{
controller = new AsynchronousFileImpl(executor, pollerExecutor);

0 comments on commit ccce5d4

Please sign in to comment.