Hi,
Sorry for the late reply!
I've changed according to your suggestion, the test fails with a
NullPointerException without the fix so at least it will test the previous
error.
[[[
Index:
subversion/bindings/javahl/src/org/apache/subversion/javahl/NativeException.java
===
---
subversion/bindings/javahl/src/org/apache/subversion/javahl/NativeException.java
(revision 1902721)
+++
subversion/bindings/javahl/src/org/apache/subversion/javahl/NativeException.java
(working copy)
@@ -86,7 +86,11 @@
*/
public String getMessage()
{
-StringBuffer msg = new StringBuffer(super.getMessage());
+StringBuilder msg = new StringBuilder();
+String message = super.getMessage();
+if (message != null) {
+msg.append(message);
+}
// ### This might be better off in JNIUtil::handleSVNError().
String src = getSource();
if (src != null)
Index:
subversion/bindings/javahl/src/org/tigris/subversion/javahl/NativeException.java
===
---
subversion/bindings/javahl/src/org/tigris/subversion/javahl/NativeException.java
(revision 1902721)
+++
subversion/bindings/javahl/src/org/tigris/subversion/javahl/NativeException.java
(working copy)
@@ -85,7 +85,11 @@
*/
public String getMessage()
{
-StringBuffer msg = new StringBuffer(super.getMessage());
+StringBuilder msg = new StringBuilder();
+String message = super.getMessage();
+if (message != null) {
+msg.append(message);
+}
// ### This might be better off in JNIUtil::handleSVNError().
String src = getSource();
if (src != null)
Index:
subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
===
---
subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
(revision 1902721)
+++
subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
(working copy)
@@ -27,6 +27,7 @@
import org.apache.subversion.javahl.callback.*;
import org.apache.subversion.javahl.remote.*;
import org.apache.subversion.javahl.types.*;
+import org.apache.subversion.javahl.NativeException;
import java.io.File;
import java.io.FileOutputStream;
@@ -4747,6 +4748,17 @@
}
/**
+ * Test getMessage in NativeException.
+ * @throws Throwable
+ */
+public void testGetMessage() throws Throwable
+{
+ /* NativeException with a null message previously threw a
NullPointerException */
+ assertEquals("", new NativeException(null, null, null,
0).getMessage());
+ assertEquals("messagesvn: source: (apr_err=0)", new
NativeException("message", "source", null, 0).getMessage());+}
+
+/**
* @return file converted into a -- possibly
* canonical-ized -- Subversion-internal path
* representation.
Index:
subversion/bindings/javahl/tests/org/tigris/subversion/javahl/BasicTests.java
===
---
subversion/bindings/javahl/tests/org/tigris/subversion/javahl/BasicTests.java
(revision 1902721)
+++
subversion/bindings/javahl/tests/org/tigris/subversion/javahl/BasicTests.java
(working copy)
@@ -22,6 +22,8 @@
*/
package org.tigris.subversion.javahl;
+import org.tigris.subversion.javahl.NativeException;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
@@ -3321,6 +3323,17 @@
}
/**
+ * Test getMessage in NativeException.
+ * @throws Throwable
+ */
+public void testGetMessage() throws Throwable
+{
+ /* NativeException with a null message previously threw a
NullPointerException */
+ assertEquals("", new NativeException(null, null, 0).getMessage());
+ assertEquals("messagesvn: source: (apr_err=0)", new
NativeException("message", "source", 0).getMessage());
+}
+
+/**
* @return file converted into a -- possibly
* canonical-ized -- Subversion-internal path
* representation.
]]]
One last thing: When committing this, I would like to give you due credit
[1] as Patch by. Is it ok that I use your name/e-mail this way or do you
want it some other way?
Kind regards,
Daniel Sahlberg
[1]
https://subversion.apache.org/docs/community-guide/conventions.html#crediting
Den mån 18 juli 2022 kl 09:36 skrev Thomas Singer :
> Hi Daniel,
>
> Thanks for the quick investigation. I would simplify the test:
>
> > @Test
> > public void testGetMessage() {
> > assertEquals("", new NativeException(null, null, null,
> 0).getMessage());
> > assertEquals("messagesvn: source: )apr_err=0)", new
> NativeException("message", "source", null, 0).getMessage());
> > }
>
> --
> Best regards,
> Thomas Singer
>
>
>
> On 2022-07-16 22:49, Dan