Repository: tomee
Updated Branches:
  refs/heads/master 7df9e6740 -> 6098bfacc


Patch from katya-stoycheva to make ivmcontext fail on close if configured as 
such, thanks Katya


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/6098bfac
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/6098bfac
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/6098bfac

Branch: refs/heads/master
Commit: 6098bfacc3e8cf100eb3672ce7caf2ad6191f436
Parents: 7df9e67
Author: rmannibucau <rmannibu...@apache.org>
Authored: Wed Jun 21 09:17:59 2017 +0200
Committer: rmannibucau <rmannibu...@apache.org>
Committed: Wed Jun 21 09:17:59 2017 +0200

----------------------------------------------------------------------
 .../openejb/core/ivm/naming/IvmContext.java     |  1 +
 .../openejb/core/ivm/naming/IvmContextTest.java | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/6098bfac/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/IvmContext.java
----------------------------------------------------------------------
diff --git 
a/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/IvmContext.java
 
b/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/IvmContext.java
index 1644122..574ea11 100644
--- 
a/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/IvmContext.java
+++ 
b/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/IvmContext.java
@@ -489,6 +489,7 @@ public class IvmContext implements Context, Serializable {
     }
 
     public void close() throws NamingException {
+        checkReadOnly();
     }
 
     /*

http://git-wip-us.apache.org/repos/asf/tomee/blob/6098bfac/container/openejb-core/src/test/java/org/apache/openejb/core/ivm/naming/IvmContextTest.java
----------------------------------------------------------------------
diff --git 
a/container/openejb-core/src/test/java/org/apache/openejb/core/ivm/naming/IvmContextTest.java
 
b/container/openejb-core/src/test/java/org/apache/openejb/core/ivm/naming/IvmContextTest.java
index 8db410b..9549ba2 100644
--- 
a/container/openejb-core/src/test/java/org/apache/openejb/core/ivm/naming/IvmContextTest.java
+++ 
b/container/openejb-core/src/test/java/org/apache/openejb/core/ivm/naming/IvmContextTest.java
@@ -334,6 +334,26 @@ public class IvmContextTest extends TestCase {
         }
     }
 
+    public void testCloseNoExceptionByDefault() throws NamingException {
+        final IvmContext context = new IvmContext();
+        try {
+            context.close();
+        } catch (OperationNotSupportedException e) {
+            fail();
+        }
+    }
+
+    public void testCloseThrowsExceptionIfReadOnly() throws NamingException {
+        final IvmContext context = new IvmContext();
+        context.setReadOnly(true);
+        try {
+            context.close();
+            fail();
+        } catch (OperationNotSupportedException e) {
+            //ok
+        }
+    }
+
     private void assertContextEntry(final Context context, final String s, 
final Object expected) throws javax.naming.NamingException {
         assertLookup(context, s, expected);
     }

Reply via email to