You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by th...@apache.org on 2013/10/16 16:15:50 UTC
svn commit: r1532775 - in
/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util:
BundleReader.java BundleWriter.java
Author: thomasm
Date: Wed Oct 16 14:15:49 2013
New Revision: 1532775
URL: http://svn.apache.org/r1532775
Log:
JCR-3684 BundleWriter: Unexpected error while writing NAME value (don't swallow the root cause)
Modified:
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleWriter.java
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java?rev=1532775&r1=1532774&r2=1532775&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java Wed Oct 16 14:15:49 2013
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.core.persi
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.apache.commons.io.IOExceptionWithCause;
import org.apache.commons.io.input.CountingInputStream;
import org.apache.jackrabbit.core.id.NodeId;
import org.apache.jackrabbit.core.id.PropertyId;
@@ -338,7 +339,8 @@ class BundleReader {
String[] blobIds = new String[count];
for (int i = 0; i < count; i++) {
InternalValue val;
- switch (entry.getType()) {
+ int type = entry.getType();
+ switch (type) {
case PropertyType.BINARY:
int size = in.readInt();
if (size == BundleBinding.BINARY_IN_DATA_STORE) {
@@ -360,7 +362,7 @@ class BundleReader {
throw e;
}
} catch (Exception e) {
- throw new IOException("Unable to create property value: " + e.toString());
+ throw new IOExceptionWithCause("Unable to create property value: " + e.toString(), e);
}
} else {
// short values into memory
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleWriter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleWriter.java?rev=1532775&r1=1532774&r2=1532775&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleWriter.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleWriter.java Wed Oct 16 14:15:49 2013
@@ -29,6 +29,7 @@ import java.util.GregorianCalendar;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
+import org.apache.commons.io.IOExceptionWithCause;
import org.apache.commons.io.IOUtils;
import org.apache.jackrabbit.core.id.NodeId;
import org.apache.jackrabbit.core.value.InternalValue;
@@ -244,7 +245,7 @@ class BundleWriter {
String msg = "Error while storing blob. id="
+ state.getId() + " idx=" + i + " size=" + size;
log.error(msg, e);
- throw new IOException(msg);
+ throw new IOExceptionWithCause(msg, e);
}
try {
// replace value instance with value
@@ -275,47 +276,42 @@ class BundleWriter {
String msg = "Error while storing blob. id="
+ state.getId() + " idx=" + i + " value=" + val;
log.error(msg, e);
- throw new IOException(msg);
+ throw new IOExceptionWithCause(msg, e);
}
break;
case PropertyType.DOUBLE:
try {
out.writeDouble(val.getDouble());
} catch (RepositoryException e) {
- // should never occur
- throw new IOException("Unexpected error while writing DOUBLE value.");
+ throw convertToIOException(type, e);
}
break;
case PropertyType.DECIMAL:
try {
writeDecimal(val.getDecimal());
} catch (RepositoryException e) {
- // should never occur
- throw new IOException("Unexpected error while writing DECIMAL value.");
+ throw convertToIOException(type, e);
}
break;
case PropertyType.LONG:
try {
writeVarLong(val.getLong());
} catch (RepositoryException e) {
- // should never occur
- throw new IOException("Unexpected error while writing LONG value.");
+ throw convertToIOException(type, e);
}
break;
case PropertyType.BOOLEAN:
try {
out.writeBoolean(val.getBoolean());
} catch (RepositoryException e) {
- // should never occur
- throw new IOException("Unexpected error while writing BOOLEAN value.");
+ throw convertToIOException(type, e);
}
break;
case PropertyType.NAME:
try {
writeName(val.getName());
} catch (RepositoryException e) {
- // should never occur
- throw new IOException("Unexpected error while writing NAME value.");
+ throw convertToIOException(type, e);
}
break;
case PropertyType.WEAKREFERENCE:
@@ -326,8 +322,7 @@ class BundleWriter {
try {
writeDate(val.getCalendar());
} catch (RepositoryException e) {
- // should never occur
- throw new IOException("Unexpected error while writing DATE value.");
+ throw convertToIOException(type, e);
}
break;
case PropertyType.STRING:
@@ -340,6 +335,13 @@ class BundleWriter {
}
}
}
+
+ private static IOException convertToIOException(int propertyType, Exception e) {
+ String typeName = PropertyType.nameFromValue(propertyType);
+ String message = "Unexpected error for property type "+ typeName +" value.";
+ log.error(message, e);
+ return new IOExceptionWithCause(message, e);
+ }
/**
* Write a small binary value and return the data.
@@ -370,7 +372,7 @@ class BundleWriter {
String msg = "Error while storing blob. id="
+ state.getId() + " idx=" + i + " value=" + value;
log.error(msg, e);
- throw new IOException(msg);
+ throw new IOExceptionWithCause(msg, e);
}
}