Example usage for org.apache.commons.lang3 SerializationException printStackTrace

List of usage examples for org.apache.commons.lang3 SerializationException printStackTrace

Introduction

In this page you can find the example usage for org.apache.commons.lang3 SerializationException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:example.RepoChain.java

@Override
public String query(ChaincodeStub stub, String function, String[] args) {
    String returnString;// w w  w  .  j ava  2 s.  c  om
    switch (function) {
    case "query":
        if (args.length < 5) {
            returnString = "Incorrect query parameters";
        } else {
            String reqkey = (args[4].equalsIgnoreCase("M") ? "" : "~") + getKeyFromArgs(args);
            log.info("Querying ledger with key - " + reqkey);
            RepoContract repoObj = RepoContract.toRepoObj(stub.getRawState(reqkey).toByteArray());
            log.info("Returned repoObj - " + repoObj);
            returnString = repoObj.toString();
        }
        break;
    case "keys":
        returnString = stub.rangeQueryState(args[0], args[1]).keySet().toString();
        break;
    case "trades":
        log.info("Inside all trades query");
        Map<String, ByteString> allTrades = null;
        StringBuffer sb = new StringBuffer("");

        try {
            allTrades = stub.rangeQueryRawState("", "");
            for (Map.Entry<String, ByteString> repoIter : allTrades.entrySet()) {
                RepoContract iterTrade = null;
                try {
                    iterTrade = RepoContract.toRepoObj(repoIter.getValue().toByteArray());
                } catch (SerializationException e) {
                    log.info("Failed to deserialize for key " + repoIter.getKey());
                    continue;
                }
                sb.append("==> " + iterTrade.toString() + "\n");
            }
        } catch (Exception e) {
            e.printStackTrace();
            log.info(e.getMessage());
        }
        log.info(sb.toString());
        returnString = sb.toString();
        break;

    default:
        returnString = "Invalid function input";
    }
    return returnString;
}

From source file:eu.stratosphere.api.common.typeutils.SerializerTestBase.java

@Test
public void testSerializabilityAndEquals() {
    try {//www  . j ava  2  s  . c o  m
        TypeSerializer<T> ser1 = getSerializer();
        TypeSerializer<T> ser2;
        try {
            ser2 = SerializationUtils.clone(ser1);
        } catch (SerializationException e) {
            fail("The serializer is not serializable.");
            return;
        }

        assertEquals("The copy of the serializer is not equal to the original one.", ser1, ser2);
    } catch (Exception e) {
        System.err.println(e.getMessage());
        e.printStackTrace();
        fail("Exception in test: " + e.getMessage());
    }
}

From source file:org.apache.flink.api.common.typeutils.SerializerTestBase.java

@Test
public void testSerializabilityAndEquals() {
    try {/*from  www  .java2  s.c o m*/
        TypeSerializer<T> ser1 = getSerializer();
        TypeSerializer<T> ser2;
        try {
            ser2 = SerializationUtils.clone(ser1);
        } catch (SerializationException e) {
            fail("The serializer is not serializable: " + e);
            return;
        }

        assertEquals("The copy of the serializer is not equal to the original one.", ser1, ser2);
    } catch (Exception e) {
        System.err.println(e.getMessage());
        e.printStackTrace();
        fail("Exception in test: " + e.getMessage());
    }
}