[jboss-cvs] JBoss Messaging SVN: r5373 - in trunk: native/src and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Nov 17 13:56:11 EST 2008


Author: clebert.suconic at jboss.com
Date: 2008-11-17 13:56:11 -0500 (Mon, 17 Nov 2008)
New Revision: 5373

Modified:
   trunk/native/bin/libJBMLibAIO64.so
   trunk/native/src/AIOController.cpp
   trunk/native/src/AsyncFile.cpp
   trunk/native/src/LibAIOController.cpp
   trunk/native/src/Version.h
   trunk/src/main/org/jboss/messaging/core/asyncio/impl/AsynchronousFileImpl.java
   trunk/tests/src/org/jboss/messaging/tests/integration/asyncio/AIOTestBase.java
   trunk/tests/src/org/jboss/messaging/tests/integration/asyncio/SingleThreadWriteNativeTest.java
Log:
JBMESSAGING-1454 - Avoiding crash when the file can't be created on the native layer

Modified: trunk/native/bin/libJBMLibAIO64.so
===================================================================
(Binary files differ)

Modified: trunk/native/src/AIOController.cpp
===================================================================
--- trunk/native/src/AIOController.cpp	2008-11-17 17:07:33 UTC (rev 5372)
+++ trunk/native/src/AIOController.cpp	2008-11-17 18:56:11 UTC (rev 5373)
@@ -49,7 +49,10 @@
 
 void AIOController::destroy(THREAD_CONTEXT context)
 {
-	context->DeleteGlobalRef(logger);
+	if (logger != 0)
+	{
+		context->DeleteGlobalRef(logger);
+	}
 }
 
 /*

Modified: trunk/native/src/AsyncFile.cpp
===================================================================
--- trunk/native/src/AsyncFile.cpp	2008-11-17 17:07:33 UTC (rev 5372)
+++ trunk/native/src/AsyncFile.cpp	2008-11-17 18:56:11 UTC (rev 5373)
@@ -73,6 +73,7 @@
 	fileHandle = ::open(fileName.data(),  O_RDWR | O_CREAT | O_DIRECT, 0666);
 	if (fileHandle < 0)
 	{
+		io_queue_release(aioContext);
 		throw AIOException(1, "Can't open file"); 
 	}
 	

Modified: trunk/native/src/LibAIOController.cpp
===================================================================
--- trunk/native/src/LibAIOController.cpp	2008-11-17 17:07:33 UTC (rev 5372)
+++ trunk/native/src/LibAIOController.cpp	2008-11-17 18:56:11 UTC (rev 5373)
@@ -45,11 +45,12 @@
 JNIEXPORT jlong JNICALL Java_org_jboss_messaging_core_asyncio_impl_AsynchronousFileImpl_init
   (JNIEnv * env, jclass clazz, jstring jstrFileName, jint maxIO, jobject logger)
 {
+	AIOController * controller = 0;
 	try
 	{
 		std::string fileName = convertJavaString(env, jstrFileName);
 		
-		AIOController * controller = new AIOController(fileName, (int) maxIO);
+		controller = new AIOController(fileName, (int) maxIO);
 		controller->done = env->GetMethodID(clazz,"callbackDone","(Lorg/jboss/messaging/core/asyncio/AIOCallback;Ljava/nio/ByteBuffer;)V");
 		if (!controller->done) return 0;
 		
@@ -70,6 +71,10 @@
 	    return (jlong)controller;
 	}
 	catch (AIOException& e){
+		if (controller != 0)
+		{
+			delete controller;
+		}
 		throwException(env, "java/lang/RuntimeException", e.what());
 		return 0;
 	}
@@ -180,9 +185,12 @@
 {
 	try
 	{
-		AIOController * controller = (AIOController *) controllerAddress;
-		controller->destroy(env);
-		delete controller;
+		if (controllerAddress != 0)
+		{
+			AIOController * controller = (AIOController *) controllerAddress;
+			controller->destroy(env);
+			delete controller;
+		}
 	}
 	catch (AIOException& e)
 	{

Modified: trunk/native/src/Version.h
===================================================================
--- trunk/native/src/Version.h	2008-11-17 17:07:33 UTC (rev 5372)
+++ trunk/native/src/Version.h	2008-11-17 18:56:11 UTC (rev 5373)
@@ -1,5 +1,5 @@
 
 #ifndef _VERSION_NATIVE_AIO
-#define _VERSION_NATIVE_AIO 15
+#define _VERSION_NATIVE_AIO 16
 #endif
 

Modified: trunk/src/main/org/jboss/messaging/core/asyncio/impl/AsynchronousFileImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/asyncio/impl/AsynchronousFileImpl.java	2008-11-17 17:07:33 UTC (rev 5372)
+++ trunk/src/main/org/jboss/messaging/core/asyncio/impl/AsynchronousFileImpl.java	2008-11-17 18:56:11 UTC (rev 5373)
@@ -53,7 +53,7 @@
 
    private static boolean loaded = false;
 
-   private static int EXPECTED_NATIVE_VERSION = 15;
+   private static int EXPECTED_NATIVE_VERSION = 16;
 
    static void addMax(final int io)
    {
@@ -159,8 +159,8 @@
 
          opened = true;
          this.fileName = fileName;
+         addMax(this.maxIO);
          handler = init(fileName, this.maxIO, log);
-         addMax(this.maxIO);
       }
       finally
       {

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/asyncio/AIOTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/asyncio/AIOTestBase.java	2008-11-17 17:07:33 UTC (rev 5372)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/asyncio/AIOTestBase.java	2008-11-17 18:56:11 UTC (rev 5373)
@@ -30,6 +30,7 @@
 import org.jboss.messaging.core.asyncio.AIOCallback;
 import org.jboss.messaging.core.asyncio.impl.AsynchronousFileImpl;
 import org.jboss.messaging.tests.util.UnitTestCase;
+import org.jboss.messaging.util.UUIDGenerator;
 
 /**
  * The base class for AIO Tests
@@ -40,7 +41,7 @@
 {
    // The AIO Test must use a local filesystem. Sometimes $HOME is on a NFS on
    // most enterprise systems
-   protected String fileDir = System.getProperty("java.io.tmpdir", "/tmp") + "/journal-test";
+   protected String fileDir = System.getProperty("java.io.tmpdir", "/tmp") + "/journal-test-" + UUIDGenerator.getInstance().generateSimpleStringUUID().toString();
 
    protected String FILE_NAME = fileDir + "/fileUsedOnNativeTests.log";
 

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/asyncio/SingleThreadWriteNativeTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/asyncio/SingleThreadWriteNativeTest.java	2008-11-17 17:07:33 UTC (rev 5372)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/asyncio/SingleThreadWriteNativeTest.java	2008-11-17 18:56:11 UTC (rev 5373)
@@ -84,7 +84,25 @@
 
       }
    }
+   
+   public void testFileNonExistent() throws Exception
+   {
+      final AsynchronousFileImpl controller = new AsynchronousFileImpl();
+      for (int i = 0; i < 1000; i++)
+      {
+         try
+         {
+            controller.open("/non-existent/IDontExist.error", 10000);
+            fail ("Exception expected! The test could create a file called /non-existent/IDontExist.error when it was supposed to fail.");
+         }
+         catch (Throwable ignored)
+         {
+         }
+         controller.close();
 
+      }
+   }
+
    /**
     * This test is validating if the AIO layer can open two different
     * simultaneous files without loose any callbacks. This test made the native




More information about the jboss-cvs-commits mailing list