jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1411132 - /jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/RmiRepositoryFactory.java
Date Mon, 19 Nov 2012 11:37:40 GMT
Author: alexparvulescu
Date: Mon Nov 19 11:37:39 2012
New Revision: 1411132

URL: http://svn.apache.org/viewvc?rev=1411132&view=rev
Log:
JCR-3459 RmiRepositoryFactory regression, invalid stream header

Modified:
    jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/RmiRepositoryFactory.java

Modified: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/RmiRepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/RmiRepositoryFactory.java?rev=1411132&r1=1411131&r2=1411132&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/RmiRepositoryFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/repository/RmiRepositoryFactory.java
Mon Nov 19 11:37:39 2012
@@ -36,6 +36,7 @@ import javax.naming.InitialContext;
 import javax.naming.NamingException;
 
 import org.apache.jackrabbit.rmi.client.ClientAdapterFactory;
+import org.apache.jackrabbit.rmi.client.LocalAdapterFactory;
 import org.apache.jackrabbit.rmi.client.SafeClientRepository;
 import org.apache.jackrabbit.rmi.remote.RemoteRepository;
 
@@ -74,36 +75,43 @@ public class RmiRepositoryFactory implem
         }
     }
 
-    private Repository getUrlRepository(final URL url) throws RepositoryException {
-    	return new SafeClientRepository(new ClientAdapterFactory()) {
-			
-			@Override
-			protected RemoteRepository getRemoteRepository() throws RemoteException {
-		        try {
-		            InputStream stream = url.openStream();
-		            try {
-		                Object remote = new ObjectInputStream(stream).readObject();
-		                if (remote instanceof RemoteRepository) {
-		                    return (RemoteRepository) remote;
-		                } else {
-		                    throw new RemoteException(
-		                            "The resource at URL " + url
-		                            + " is not a remote repository stub: "
-		                            + remote);
-		                }
-		            } finally {
-		                stream.close();
-		            }
-		        } catch (ClassNotFoundException e) {
-		            throw new RemoteException(
-		                    "The resource at URL " + url
-		                    + " requires a class that is not available", e);
-		        } catch (IOException e) {
-		            throw new RemoteException(
-		                    "Failed to read the resource at URL " + url, e);
-		        }
-			}
-		};
+    private Repository getUrlRepository(final URL url)
+            throws RepositoryException {
+        return new SafeClientRepositoryUrl(url, new ClientAdapterFactory());
+    }
+
+    private static class SafeClientRepositoryUrl extends SafeClientRepository {
+
+        private final URL url;
+
+        public SafeClientRepositoryUrl(URL url, LocalAdapterFactory factory) {
+            super(factory);
+            this.url = url;
+        }
+
+        @Override
+        protected RemoteRepository getRemoteRepository() throws RemoteException {
+            try {
+                InputStream stream = url.openStream();
+                try {
+                    Object remote = new ObjectInputStream(stream).readObject();
+                    if (remote instanceof RemoteRepository) {
+                        return (RemoteRepository) remote;
+                    } else {
+                        throw new RemoteException("The resource at URL " + url
+                                + " is not a remote repository stub: " + remote);
+                    }
+                } finally {
+                    stream.close();
+                }
+            } catch (ClassNotFoundException e) {
+                throw new RemoteException("The resource at URL " + url
+                        + " requires a class that is not available", e);
+            } catch (IOException e) {
+                throw new RemoteException("Failed to read the resource at URL "
+                        + url, e);
+            }
+        }
     }
 
     @SuppressWarnings("rawtypes")



Mime
View raw message