You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2013/06/17 02:47:21 UTC

svn commit: r1493619 - in /subversion/branches/javahl-ra/subversion/bindings/javahl: native/ src/org/apache/subversion/javahl/ src/org/apache/subversion/javahl/remote/

Author: brane
Date: Mon Jun 17 00:47:20 2013
New Revision: 1493619

URL: http://svn.apache.org/r1493619
Log:
On the javahl-ra branch:
Throw different exceptions for redirect cycles and too many redirects,
so that the API consumer can easily tell the difference.

[in subversion/bindings/javahl/src/org/apache/subversion/javahl]
* remote/RetryOpenSession.java: New exception class.
* remote/RemoteFactory.java, ISVNClient.java (openRemoteSession):
   Update docs about when remote.RetryOpenSession is thrown.

[in subversion/bindings/javahl/native]
* RemoteSession.cpp (RemoteSession::RemoteSession): Throw RetryOpenSession
   if there were too many redirects but no cycle was detected.

Added:
    subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RetryOpenSession.java
Modified:
    subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.cpp
    subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java
    subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteFactory.java

Modified: subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.cpp?rev=1493619&r1=1493618&r2=1493619&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.cpp (original)
+++ subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.cpp Mon Jun 17 00:47:20 2013
@@ -205,16 +205,12 @@ RemoteSession::RemoteSession(jobject* jt
         }
     }
 
-  if (corrected_url)
+  if (cycle_detected)
     {
       jstring exmsg = JNIUtil::makeJString(
-          (cycle_detected
-           ? apr_psprintf(pool.getPool(),
-                          _("Redirect cycle detected for URL '%s'"),
-                          corrected_url)
-           : _("Too many redirects")));
-      if (JNIUtil::isJavaExceptionThrown())
-        return;
+          apr_psprintf(pool.getPool(),
+                       _("Redirect cycle detected for URL '%s'"),
+                       corrected_url));
 
       jclass excls = env->FindClass(
           JAVA_PACKAGE "/SubversionException");
@@ -234,6 +230,34 @@ RemoteSession::RemoteSession(jobject* jt
       return;
     }
 
+  if (corrected_url)
+    {
+      jstring exmsg = JNIUtil::makeJString(_("Too many redirects"));
+      if (JNIUtil::isJavaExceptionThrown())
+        return;
+
+      jstring exurl = JNIUtil::makeJString(corrected_url);
+      if (JNIUtil::isJavaExceptionThrown())
+        return;
+
+      jclass excls = env->FindClass(
+          JAVA_PACKAGE "/remote/RetryOpenSession");
+      if (JNIUtil::isJavaExceptionThrown())
+        return;
+
+      static jmethodID exctor = 0;
+      if (exctor == 0)
+        {
+          exctor = env->GetMethodID(excls, "<init>", "(JJ)V");
+          if (JNIUtil::isJavaExceptionThrown())
+            return;
+        }
+
+      jobject ex = env->NewObject(excls, exctor, exmsg, exurl);
+      env->Throw(static_cast<jthrowable>(ex));
+      return;
+    }
+
   *jthis_out = jremoteSession;
 }
 

Modified: subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java?rev=1493619&r1=1493618&r2=1493619&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java (original)
+++ subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java Mon Jun 17 00:47:20 2013
@@ -1150,7 +1150,8 @@ public interface ISVNClient
      * Open a persistent session to a repository.
      * @param path A path in a working copy from which the
      *        session URL is derived.
-     * @throws SubversionException If URL redirects cannot be followed
+     * @throws remote.RetryOpenSession If the session URL was redirected
+     * @throws SubversionException If an URL redirect cycle was detected
      * @throws ClientException
      * @note The session object inherits the progress callback,
      *       configuration directory and authentication info.
@@ -1167,7 +1168,8 @@ public interface ISVNClient
      *        if the given URL is redirected.
      * @throws IllegalArgumentException If <code>retryAttempts</code>
      *         is not positive
-     * @throws SubversionException If URL redirects cannot be followed
+     * @throws remote.RetryOpenSession If the session URL was redirected
+     * @throws SubversionException If an URL redirect cycle was detected
      * @throws ClientException
      * @note The session object inherits the progress callback,
      *       configuration directory and authentication info.

Modified: subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteFactory.java
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteFactory.java?rev=1493619&r1=1493618&r2=1493619&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteFactory.java (original)
+++ subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteFactory.java Mon Jun 17 00:47:20 2013
@@ -120,7 +120,8 @@ public class RemoteFactory
     /**
      * Open a persistent session to a repository.
      * @param url The initial session root URL.
-     * @throws SubversionException If URL redirects cannot be followed
+     * @throws RetryOpenSession If the session URL was redirected
+     * @throws SubversionException If an URL redirect cycle was detected
      * @throws ClientException
      * @note The URL can point to a subtree of the repository.
      * @note The session object inherits the progress callback,
@@ -140,7 +141,8 @@ public class RemoteFactory
      *        if the given URL is redirected.
      * @throws IllegalArgumentException If <code>retryAttempts</code>
      *         is not positive
-     * @throws SubversionException If URL redirects cannot be followed
+     * @throws RetryOpenSession If the session URL was redirected
+     * @throws SubversionException If an URL redirect cycle was detected
      * @throws ClientException
      * @note The URL can point to a subtree of the repository.
      * @note The session object inherits the progress callback,
@@ -161,7 +163,8 @@ public class RemoteFactory
      * @param url The initial session root URL.
      * @param reposUUID The expected repository UUID; may not be null..
      * @throws IllegalArgumentException If <code>reposUUID</code> is null.
-     * @throws SubversionException If URL redirects cannot be followed
+     * @throws RetryOpenSession If the session URL was redirected
+     * @throws SubversionException If an URL redirect cycle was detected
      * @throws ClientException
      * @note The URL can point to a subtree of the repository.
      * @note If the UUID does not match the repository, this function fails.
@@ -185,7 +188,8 @@ public class RemoteFactory
      *        if the given URL is redirected.
      * @throws IllegalArgumentException If <code>reposUUID</code> is null
      *         or <code>retryAttempts</code> is not positive
-     * @throws SubversionException If URL redirects cannot be followed
+     * @throws RetryOpenSession If the session URL was redirected
+     * @throws SubversionException If an URL redirect cycle was detected
      * @throws ClientException
      * @note The URL can point to a subtree of the repository.
      * @note If the UUID does not match the repository, this function fails.

Added: subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RetryOpenSession.java
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RetryOpenSession.java?rev=1493619&view=auto
==============================================================================
--- subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RetryOpenSession.java (added)
+++ subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RetryOpenSession.java Mon Jun 17 00:47:20 2013
@@ -0,0 +1,57 @@
+/**
+ * @copyright
+ * ====================================================================
+ *    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.
+ * ====================================================================
+ * @endcopyright
+ */
+
+package org.apache.subversion.javahl.remote;
+
+import org.apache.subversion.javahl.SubversionException;
+
+/**
+ * This checked exception is thrown only from ISVNClient.openRemoteSession
+ * or RemoteFactory.openRemoteSession if a session could not be opened
+ * due to a redirect.
+ */
+public class RetryOpenSession extends SubversionException
+{
+    // Update the serialVersionUID when there is a incompatible change
+    // made to this class.
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * This constructor is only called from native code.
+     */
+    protected RetryOpenSession(String message, String correctedUrl)
+    {
+        super(message);
+        this.correctedUrl = correctedUrl;
+    }
+
+    /**
+     * @return the corrected URL for the session.
+     */
+    public String getCorrectedUrl()
+    {
+        return correctedUrl;
+    }
+
+    private final String correctedUrl;
+}