Return-Path: X-Original-To: apmail-jackrabbit-commits-archive@www.apache.org Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 27D16104F8 for ; Wed, 16 Oct 2013 14:16:12 +0000 (UTC) Received: (qmail 12216 invoked by uid 500); 16 Oct 2013 14:16:12 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 12184 invoked by uid 500); 16 Oct 2013 14:16:12 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 12177 invoked by uid 99); 16 Oct 2013 14:16:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Oct 2013 14:16:11 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Oct 2013 14:16:10 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 33BD62388868; Wed, 16 Oct 2013 14:15:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1532775 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util: BundleReader.java BundleWriter.java Date: Wed, 16 Oct 2013 14:15:50 -0000 To: commits@jackrabbit.apache.org From: thomasm@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131016141550.33BD62388868@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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); } }