subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1664609 - in /subversion/trunk/subversion/bindings/javahl: native/JNIUtil.cpp tests/org/apache/subversion/javahl/BasicTests.java tests/org/apache/subversion/javahl/SVNRemoteTests.java tests/org/apache/subversion/javahl/UtilTests.java
Date Fri, 06 Mar 2015 13:07:01 GMT
Author: rhuijben
Date: Fri Mar  6 13:07:00 2015
New Revision: 1664609

URL: http://svn.apache.org/r1664609
Log:
Tweak JavaHL error text generation to create errors that only contains
generic error messages when the creator of the error chain intended
to add these to the chain.

This makes the creation more similar to what our standard error printing
in 'svn' would do and avoids bad messages in cases such as 'bad filename'
when the code just used that error code to tell that a registry key does
not exist, but added their own detailed message.

Note that all these messages are localized, etc. so end user applications
can never rely on the exact messages anyway.

* subversion/bindings/javahl/tests/org/apache/subversion/javahl/UtilTests.java
  (testValidateProp): Update expected result.

* subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java
  (testGetLogMissing): Update expected result.

* subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
  (testCommitPartialMove): Update expected result.

* subversion/bindings/javahl/native/JNIUtil.cpp
  (assemble_error_message): Only show generic messages if there is no not
    generic message, and the generic message wasn't the last shown generic
    message.

Modified:
    subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp
    subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
    subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java
    subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/UtilTests.java

Modified: subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp?rev=1664609&r1=1664608&r2=1664609&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp Fri Mar  6 13:07:00 2015
@@ -435,19 +435,24 @@ ErrorMessageStack assemble_error_message
 {
   // buffer for a single error message
   char errbuf[1024];
-  apr_status_t parent_apr_err = 0;
   ErrorMessageStack message_stack;
+  apr_status_t last_generic = APR_SUCCESS;
 
   /* Pretty-print the error */
   /* Note: we can also log errors here someday. */
 
-  for (int depth = 0; err;
-       ++depth, parent_apr_err = err->apr_err, err = err->child)
+  for (; err; err = err->child)
     {
-      /* When we're recursing, don't repeat the top-level message if its
-       * the same as before. */
-      if (depth == 0 || err->apr_err != parent_apr_err)
+      if (err->message)
+        {
+          message_stack.push_back(
+              MessageStackItem(err->apr_err, err->message));
+        }
+      else if (err->apr_err != last_generic)
         {
+          /* When we're recursing, don't repeat the generic message if we
+           * just showed it. */
+
           const char *message;
           /* Is this a Subversion-specific error code? */
           if ((err->apr_err > APR_OS_START_USEERR)
@@ -471,11 +476,8 @@ ErrorMessageStack assemble_error_message
 
           message_stack.push_back(
               MessageStackItem(err->apr_err, message, true));
-        }
-      if (err->message)
-        {
-          message_stack.push_back(
-              MessageStackItem(err->apr_err, err->message));
+
+          last_generic = err->apr_err;
         }
     }
 

Modified: subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java?rev=1664609&r1=1664608&r2=1664609&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
Fri Mar  6 13:07:00 2015
@@ -1344,10 +1344,9 @@ public class BasicTests extends SVNTests
         assertNotNull("Commit of partial move did not fail", caught);
 
         List<ClientException.ErrorMessage> msgs = caught.getAllMessages();
-        assertTrue(msgs.size() >= 3);
-        assertTrue(msgs.get(0).getMessage().startsWith("Illegal target"));
-        assertTrue(msgs.get(1).getMessage().startsWith("Commit failed"));
-        assertTrue(msgs.get(2).getMessage().startsWith("Cannot commit"));
+        assertTrue(msgs.size() >= 2);
+        assertTrue(msgs.get(0).getMessage().startsWith("Commit failed"));
+        assertTrue(msgs.get(1).getMessage().startsWith("Cannot commit"));
     }
 
     /**

Modified: subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java?rev=1664609&r1=1664608&r2=1664609&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java
Fri Mar  6 13:07:00 2015
@@ -963,8 +963,8 @@ public class SVNRemoteTests extends SVNT
                            0, false, false, false, null,
                            receiver);
         } catch (ClientException ex) {
-            assertEquals("Filesystem has no item",
-                         ex.getAllMessages().get(0).getMessage());
+            assertTrue(ex.getAllMessages().get(0).getMessage().startsWith(
+                       "File not found"));
             exception = true;
         }
 

Modified: subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/UtilTests.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/UtilTests.java?rev=1664609&r1=1664608&r2=1664609&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/UtilTests.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/UtilTests.java
Fri Mar  6 13:07:00 2015
@@ -176,8 +176,8 @@ public class UtilTests extends SVNTests
                         "propcheck.file", NodeKind.file,
                         "text/plain");
         } catch (ClientException ex) {
-            assertEquals("Unrecognized line ending style",
-                         ex.getAllMessages().get(0).getMessage());
+            assertTrue(ex.getAllMessages().get(0).getMessage().startsWith(
+                       "Unrecognized line ending style"));
             caught_exception = true;
         }
         assertTrue(caught_exception);
@@ -194,7 +194,7 @@ public class UtilTests extends SVNTests
                         "text/plain", new FileInputStream(temp));
         } catch (ClientException ex) {
             assertEquals("Inconsistent line ending style",
-                         ex.getAllMessages().get(2).getMessage());
+                         ex.getAllMessages().get(1).getMessage());
             caught_exception = true;
         }
         assertTrue(caught_exception);



Mime
View raw message