Example usage for org.apache.commons.lang SerializationException getMessage

List of usage examples for org.apache.commons.lang SerializationException getMessage

Introduction

In this page you can find the example usage for org.apache.commons.lang SerializationException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.moz.fiji.mapreduce.kvstore.lib.TestInMemoryMapKeyValueStore.java

@Test
public void testNonSerializableTypes() throws Exception {
    /** A simple class which is not serializable. */
    final class NotSerialized {
    }//from  www .j  a  v a 2 s.  c om
    final Map<String, NotSerialized> map = new HashMap<String, NotSerialized>();
    map.put("lorem", new NotSerialized());
    final InMemoryMapKeyValueStore<String, NotSerialized> kvStore = InMemoryMapKeyValueStore.fromMap(map);
    final Configuration conf = new Configuration(false);
    final KeyValueStoreConfiguration kvConf = KeyValueStoreConfiguration.fromConf(conf);
    try {
        kvStore.storeToConf(kvConf);
        fail("Should have thrown a SerializationException");
    } catch (SerializationException se) {
        assertEquals("InMemoryKeyValueStore requires that its keys and values are Serializable",
                se.getMessage());
    }
}

From source file:com.ephesoft.dcma.da.dao.hibernate.BatchInstanceDaoImpl.java

/**
 * Gets the Batch Description from the SER file if available.
 * /*from  www  .  j a  v a 2 s .  c  o  m*/
 * @param uncSubfolder {@link String}
 * @return batchDescription {@link String}
 */
private String getBatchDescriptionFromSERFile(final String uncSubfolder, final String batchName) {
    String batchDescription = null;
    FileInputStream fileInputStream = null;
    if (!EphesoftStringUtil.isNullOrEmpty(uncSubfolder)) {
        final String serializedFilePath = EphesoftStringUtil.concatenate(uncSubfolder, File.separator,
                BID_SER_FILE_NAME, SERIALIZATION_EXT);
        final File serializedFile = new File(serializedFilePath);
        if (serializedFile.exists()) {
            try {

                fileInputStream = new FileInputStream(serializedFile);
                batchDescription = SerializationUtils.deserialize(fileInputStream).toString();
                serializedFile.delete();
            } catch (final IOException ioException) {
                log.info(EphesoftStringUtil.concatenate("Error during reading the serialized file. ",
                        ioException.getMessage()));
            } catch (final SerializationException serException) {
                log.error("Error during de-serializing the Batch Description: ", serException.getMessage());
            } catch (final IllegalArgumentException illegalArgumentException) {
                log.error("Error during parsing File Input Stream : ", illegalArgumentException.getMessage());
            } catch (final SecurityException securityException) {
                log.info("Unable to delete serialized file : ", securityException.getMessage());
            } finally {
                try {
                    if (fileInputStream != null) {
                        fileInputStream.close();
                    }
                } catch (final IOException ioException) {
                    if (serializedFile != null) {
                        log.error(EphesoftStringUtil.concatenate("Problem closing stream for file : ",
                                serializedFile.getName(), ioException.getMessage()));
                    }
                }
            }

        } else {
            log.info("Serialised file not found in UNC sub folder. Setting Batch Name as Batch Description.");
            batchDescription = batchName;
        }
    }
    return batchDescription;
}