commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r820919 - in /commons/sandbox/runtime/trunk/src: main/java/org/apache/commons/runtime/io/ main/native/include/ main/native/os/unix/ main/native/os/win32/ main/native/shared/ test/org/apache/commons/runtime/
Date Fri, 02 Oct 2009 07:46:53 GMT
Author: mturk
Date: Fri Oct  2 07:46:52 2009
New Revision: 820919

URL: http://svn.apache.org/viewvc?rev=820919&view=rev
Log:
Set descriptor error directly to attached object

Added:
    commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestCleanup.java   (with
props)
Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileSystem.java
    commons/sandbox/runtime/trunk/src/main/native/include/acr_descriptor.h
    commons/sandbox/runtime/trunk/src/main/native/include/acr_file.h
    commons/sandbox/runtime/trunk/src/main/native/os/unix/fsysio.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/fsysio.c
    commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c
    commons/sandbox/runtime/trunk/src/main/native/shared/fsysio.c
    commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileSystem.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileSystem.java?rev=820919&r1=820918&r2=820919&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileSystem.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileSystem.java
Fri Oct  2 07:46:52 2009
@@ -31,8 +31,6 @@
 public final class FileSystem
 {
 
-    private static native void    err0(Descriptor fd);
-
     protected FileSystem()
     {
         // Nothing.
@@ -108,10 +106,7 @@
     {
         if (!fd.valid())
             throw new ClosedDescriptorException();
-        int rd = read0(fd.fd());
-        if (rd < 1)
-            err0(fd);
-        return rd;
+        return = read0(fd.fd());
     }
 
     private static native int read1(int fd, byte [] b, int off, int len);
@@ -133,10 +128,7 @@
     {
         if (!fd.valid())
             throw new ClosedDescriptorException();
-        int rd = read1(fd.fd(), b, off, len);
-        if (rd < len)
-            err0(fd);
-        return rd;
+        return read1(fd.fd(), b, off, len);
     }
 
     private static native int write0(int fd, int val);

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_descriptor.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_descriptor.h?rev=820919&r1=820918&r2=820919&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_descriptor.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_descriptor.h Fri Oct  2 07:46:52
2009
@@ -183,6 +183,16 @@
 ACR_DECLARE(int) ACR_DescriptorSetErr(JNIEnv *env, jobject obj, int err);
 
 /**
+ * Set the error number to the Descriptor object which might have
+ * weak object reference.
+ * @param env Current JNI environment
+ * @param obj Java Descriptor object use.
+ * @param err Error value to set.
+ * @return ACR error code on failure.
+ */
+ACR_DECLARE(int) ACR_DescriptorSetErrEx(JNIEnv *env, jobject obj, int err);
+
+/**
  * Set the context object to the Descriptor object.
  * @param env Current JNI environment
  * @param obj Java Descriptor object use.

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_file.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_file.h?rev=820919&r1=820918&r2=820919&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_file.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_file.h Fri Oct  2 07:46:52 2009
@@ -199,6 +199,8 @@
         BLK_ON
     }            blocking;              /**< Blocking mode              */
 
+    jobject      descriptor;            /**< File Descriptor object.
+                                         */
     /* The rest of the structure is platform specific.
      */
 #if defined(WIN32)

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/fsysio.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/fsysio.c?rev=820919&r1=820918&r2=820919&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/fsysio.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/fsysio.c Fri Oct  2 07:46:52 2009
@@ -87,6 +87,13 @@
     switch (cm) {
         case ACR_DESC_FINALIZE:
             if (dp->di > 0) {
+                acr_file_t *fp = ACR_IOH_FDATA(dp->di);
+                if (fp->descriptor) {
+                    (*_E)->DeleteWeakGlobalRef(_E, fp->descriptor);
+                    fp->descriptor = NULL;
+                }
+                fprintf(stdout, "[file] Finalize: %d\n", dp->di);
+                fflush(stdout);
                 rc = acr_ioh_clear(dp->di);
             }
             else
@@ -94,6 +101,13 @@
         break;
         case ACR_DESC_CLOSE:
             if (dp->di > 0) {
+                acr_file_t *fp = ACR_IOH_FDATA(dp->di);
+                if (fp->descriptor) {
+                    (*_E)->DeleteWeakGlobalRef(_E, fp->descriptor);
+                    fp->descriptor = NULL;
+                }
+                fprintf(stdout, "[file] Close:    %d\n", dp->di);
+                fflush(stdout);
                 rc = acr_ioh_close(dp->di);
             }
             else
@@ -115,8 +129,8 @@
     return rc;
 }
 
-static int do_fopen(ACR_JNISTDARGS, char *fname, int flags, int prot,
-                        jobject *fdo)
+static int do_fopen(JNIEnv *_E, char *fname, int flags, int prot,
+                    jobject *fdo)
 {
     int rc = 0;
     int fo = -1;
@@ -237,6 +251,7 @@
         rc = ACR_GET_OS_ERROR();
         goto finally;
     }
+    fp->descriptor = (*_E)->NewWeakGlobalRef(_E, *fdo);
 finally:
     if (rc) {
         if (fd >= 0)
@@ -258,7 +273,7 @@
     jobject fdo = NULL;
 
     WITH_CSTR(fname) {
-        rc = do_fopen(_E, _O, J2S(fname), flags, ACR_FPROT_OS_DEFAULT, &fdo);
+        rc = do_fopen(_E, J2S(fname), flags, ACR_FPROT_OS_DEFAULT, &fdo);
     } END_WITH_CSTR(fname);
 
     if (rc && !ACR_STATUS_IS_EEXIST(rc) && !(flags & ACR_FOPEN_EXCL))
{
@@ -278,7 +293,7 @@
     jobject fdo = NULL;
 
     WITH_CSTR(fname) {
-        rc = do_fopen(_E, _O, J2S(fname), flags, prot, &fdo);
+        rc = do_fopen(_E, J2S(fname), flags, prot, &fdo);
     } END_WITH_CSTR(fname);
 
     if (rc && !ACR_STATUS_IS_EEXIST(rc) && !(flags & ACR_FOPEN_EXCL))
{
@@ -341,7 +356,7 @@
         ACR_THROW_IO_IF_ERR(rc);
         return NULL;
     }
-
+    fp->descriptor = (*_E)->NewWeakGlobalRef(_E, fdo);
 finally:
     if (rc) {
         ACR_THROW_IO_IF_ERR(rc);
@@ -695,12 +710,15 @@
             rc = ACR_TIMEUP;
     }
     if (rd == 0) {
+        ACR_DescriptorSetErrEx(_E, f->descriptor, 0);
         f->err = 0;
         f->eof = 1;
         return  -1;
     }
     if (rd > 0)
         return (jint)rd;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
@@ -785,6 +803,8 @@
     }
     if (rd > 0)
         return (jint)rd;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
             f->eof = 1;
@@ -852,6 +872,7 @@
     if (rd > 0)
         return (jint)rd;
 
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
             f->eof = 1;
@@ -923,6 +944,7 @@
     if (rd > 0)
         return (jint)rd;
 
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
             f->eof = 1;
@@ -971,6 +993,8 @@
     }
     if (wr > 0)
         return (jint)wr;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
@@ -1027,6 +1051,8 @@
    (*_E)->ReleaseByteArrayElements(_E, buf, bb, JNI_ABORT);
     if (wr > 0)
         return (jint)wr;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
@@ -1087,6 +1113,8 @@
     }
     if (wr > 0)
         return (jint)wr;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
@@ -1152,6 +1180,8 @@
     }
     if (wr > 0)
         return (jint)wr;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
@@ -1246,6 +1276,8 @@
     }
     if (wr > 0)
         return (jint)wr;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
@@ -1323,6 +1355,8 @@
         x_free(iov);
     if (wr > 0)
         return (jint)wr;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
@@ -1389,6 +1423,8 @@
    (*_E)->ReleaseByteArrayElements(_E, buf, bb, JNI_ABORT);
     if (wt > 0)
         return (jint)wt;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
@@ -1459,6 +1495,8 @@
     }
     if (wt > 0)
         return (jint)wt;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
@@ -1534,6 +1572,8 @@
     }
     if (wt > 0)
         return (jint)wt;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/fsysio.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/fsysio.c?rev=820919&r1=820918&r2=820919&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/fsysio.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/fsysio.c Fri Oct  2 07:46:52 2009
@@ -110,6 +110,11 @@
     switch (cm) {
         case ACR_DESC_FINALIZE:
             if (dp->di > 0) {
+                acr_file_t *fp = ACR_IOH_FDATA(dp->di);
+                if (fp->descriptor) {
+                    (*_E)->DeleteWeakGlobalRef(_E, fp->descriptor);
+                    fp->descriptor = NULL;
+                }
                 rc = acr_ioh_clear(dp->di);
             }
             else
@@ -117,6 +122,11 @@
         break;
         case ACR_DESC_CLOSE:
             if (dp->di > 0) {
+                acr_file_t *fp = ACR_IOH_FDATA(dp->di);
+                if (fp->descriptor) {
+                    (*_E)->DeleteWeakGlobalRef(_E, fp->descriptor);
+                    fp->descriptor = NULL;
+                }
                 rc = acr_ioh_close(dp->di);
             }
             else
@@ -294,6 +304,7 @@
         rc = ACR_GET_OS_ERROR();
         goto finally;
     }
+    fp->descriptor = (*_E)->NewWeakGlobalRef(_E, *fdo);
 
 finally:
     if (rc) {
@@ -409,6 +420,7 @@
         ACR_THROW_IO_IF_ERR(rc);
         return NULL;
     }
+    fp->descriptor = (*_E)->NewWeakGlobalRef(_E, *fdo);
 
 finally:
     if (rc) {
@@ -811,13 +823,15 @@
                     return -1;
                 }
                 else {
+                    f->eof = 1;
                     ACR_THROW_IO_IF_ERR(rc);
                     return -1;
                 }
             }
             else {
                 if (rd == 0) {
-                    f->err= ERROR_IO_PENDING;
+                    f->err = ACR_TIMEUP;
+                    ACR_DescriptorSetErrEx(_E, f->descriptor, ACR_TIMEUP);
                     return -1;
                 }
             }
@@ -873,6 +887,8 @@
     }
     if (f->eof)
         return -1;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
@@ -932,6 +948,7 @@
             else {
                 if (rd == 0) {
                     f->err = ACR_TIMEUP;
+                    ACR_DescriptorSetErrEx(_E, f->descriptor, ACR_TIMEUP);
                     return 0;
                 }
                 else {
@@ -1027,6 +1044,8 @@
         return (jint)rd;
     if (f->eof)
         return -1;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
@@ -1085,6 +1104,7 @@
             else {
                 if (rd == 0) {
                     f->err = ACR_TIMEUP;
+                    ACR_DescriptorSetErrEx(_E, f->descriptor, ACR_TIMEUP);
                     return 0;
                 }
                 else {
@@ -1159,6 +1179,8 @@
         return (jint)rd;
     if (f->eof)
         return -1;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
@@ -1219,6 +1241,7 @@
             else {
                 if (rd == 0) {
                     f->err = ACR_TIMEUP;
+                    ACR_DescriptorSetErrEx(_E, f->descriptor, ACR_TIMEUP);
                     return 0;
                 }
                 else {
@@ -1296,6 +1319,8 @@
         return (jint)rd;
     if (f->eof)
         return -1;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
@@ -1397,6 +1422,8 @@
         do_unlock(f);
     if (wr)
         return (jint)wr;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
@@ -1511,6 +1538,8 @@
    (*_E)->ReleaseByteArrayElements(_E, buf, bb, JNI_ABORT);
     if (wr)
         return (jint)wr;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
@@ -1631,6 +1660,8 @@
         do_unlock(f);
     if (wr)
         return (jint)wr;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
@@ -1755,6 +1786,8 @@
         do_unlock(f);
     if (wr)
         return (jint)wr;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
@@ -1883,6 +1916,8 @@
         do_unlock(f);
     if (nbytes)
         return (jint)nbytes;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
@@ -2010,6 +2045,8 @@
         do_unlock(f);
     if (nbytes)
         return (jint)nbytes;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
@@ -2138,6 +2175,8 @@
    (*_E)->ReleaseByteArrayElements(_E, buf, bb, JNI_ABORT);
     if (nbytes)
         return (jint)nbytes;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
@@ -2268,6 +2307,8 @@
         do_unlock(f);
     if (nbytes)
         return (jint)nbytes;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:
@@ -2404,6 +2445,8 @@
         do_unlock(f);
     if (nbytes)
         return (jint)nbytes;
+
+    ACR_DescriptorSetErrEx(_E, f->descriptor, rc);
     switch (f->err = rc) {
         case 0:
         case ACR_TIMEUP:

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c?rev=820919&r1=820918&r2=820919&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c Fri Oct  2 07:46:52
2009
@@ -465,3 +465,17 @@
     }
 }
 
+ACR_DECLARE(int) ACR_DescriptorSetErrEx(ACR_JNISTDARGS, int e)
+{
+    if (_clazzn.i && _O) {
+        _O = (*_E)->NewLocalRef(_E, _O);
+        if (_O) {
+            SET_IFIELD_I(0004, _O, e);
+            (*_E)->DeleteLocalRef(_E, _O);
+        }
+        return ACR_SUCCESS;
+    }
+    else {
+        return ACR_EINVAL;
+    }
+}

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/fsysio.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/fsysio.c?rev=820919&r1=820918&r2=820919&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/fsysio.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/fsysio.c Fri Oct  2 07:46:52 2009
@@ -24,27 +24,20 @@
 #include "acr_fileio.h"
 
 
-ACR_IO_EXPORT_DECLARE(void, FileSystem, err0)(ACR_JNISTDARGS,
-                                              jobject file)
+ACR_IO_EXPORT_DECLARE(jint, FileSystem, ftype0)(ACR_JNISTDARGS,
+                                                jint file)
 {
-    int fd;
-    int rc = 0;
+    acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(file);
 
-    fd = ACR_DescriptorGetInt(_E, file);
-    if (fd < 0)
-        rc = ACR_EBADF;
-    else {
-        if (ACR_IOH_FTYPE(fd) != ACR_DT_FILE)
-            rc = ACR_EFTYPE;
-        else {
-            acr_file_t *f = (acr_file_t *)ACR_IOH_FDATA(fd);
-            if (IS_INVALID_HANDLE(f))
-                rc = ACR_EBADF;
-            else
-                rc = f->err;
-        }
+    if (ACR_IOH_FTYPE(file) != ACR_DT_FILE) {
+        ACR_THROW_IO_IF_ERR(ACR_EFTYPE);
+        return 0;
+    }
+    if (IS_INVALID_HANDLE(f)) {
+        ACR_THROW_IO_IF_ERR(ACR_EBADF);
+        return 0;
     }
-    ACR_DescriptorSetErr(_E, file, rc);
+    return f->type;
 }
 
 ACR_IO_EXPORT_DECLARE(jboolean, FileSystem, eof0)(ACR_JNISTDARGS,

Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java?rev=820919&r1=820918&r2=820919&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java (original)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java Fri Oct
 2 07:46:52 2009
@@ -62,6 +62,9 @@
         //
         suite.addTest(TestSignal.suite());
         suite.addTest(TestFileSys.suite());
+
+        // Keep this as last test
+        suite.addTest(TestCleanup.suite());
         return suite;
     }
 
@@ -70,6 +73,7 @@
         TestParams.initInstance(false);
         String[] testCaseName = { TestAll.class.getName() };
         junit.textui.TestRunner.main(testCaseName);
+
     }
 
 }

Added: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestCleanup.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestCleanup.java?rev=820919&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestCleanup.java (added)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestCleanup.java Fri
Oct  2 07:46:52 2009
@@ -0,0 +1,74 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.runtime;
+
+import org.apache.commons.runtime.exception.*;
+import java.lang.System;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import junit.framework.*;
+
+/**
+ * Cleanup tests.
+ *
+ */
+public class TestCleanup extends TestCase
+{
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite(TestCleanup.class);
+        return suite;
+    }
+
+    public void testGarbageCollection()
+        throws Exception
+    {
+        System.out.println();
+        System.out.println("Doing post test Garbage collection");
+        for (int i = 0; i < 2; i ++) {
+            System.gc();
+            try {
+                Thread.sleep(1000);
+            } catch (Throwable t) {
+                // Ignore
+            }
+        }
+    }
+
+    public void testFinalize()
+        throws Exception
+    {
+        System.out.println();
+        System.out.println("Doing post test Finalization");
+        for (int i = 0; i < 2; i ++) {
+            System.runFinalization();
+            try {
+                Thread.sleep(1000);
+            } catch (Throwable t) {
+                // Ignore
+            }
+        }
+    }
+
+    public void testDone()
+        throws Exception
+    {
+        System.out.println();
+        System.out.println("Cleanup Test done");
+    }
+}
+

Propchange: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestCleanup.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message