当前位置: 首页>>代码示例>>Java>>正文


Java SerializationException类代码示例

本文整理汇总了Java中org.apache.commons.lang.SerializationException的典型用法代码示例。如果您正苦于以下问题:Java SerializationException类的具体用法?Java SerializationException怎么用?Java SerializationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SerializationException类属于org.apache.commons.lang包,在下文中一共展示了SerializationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: next

import org.apache.commons.lang.SerializationException; //导入依赖的package包/类
@Override
public Vector next() {
  try {
    // refill the ByteBuffer if not enough bytes left to read
    if (bb.remaining() < Ints.BYTES)
      if (refill() < Ints.BYTES)
        throw new IllegalStateException("Could not read from input file");
    // peek the size of the vector
    bb.mark();
    // vector size in bytes = int + long + size * (int + double)
    final int vectorBytes = (bb.getInt() + 1) * (Ints.BYTES + Doubles.BYTES);
    bb.reset();
    if (bb.remaining() < vectorBytes)
      if (refill() < vectorBytes)
        throw new IllegalStateException("Internal vector buffer too small");
    // now we are sure that the ByteBuffer contains the whole next vector
    current.read(bb);
  } catch (IOException e) {
    e.printStackTrace();
    throw new SerializationException();
  }
  numReads++;
  return current;
}
 
开发者ID:gdfm,项目名称:sssj,代码行数:25,代码来源:BinaryVectorStreamReader.java

示例2: saveResult

import org.apache.commons.lang.SerializationException; //导入依赖的package包/类
private static void saveResult(final AnalysisResultFuture result, final Resource resultResource) {
    final AnalysisResultSaveHandler analysisResultSaveHandler =
            new AnalysisResultSaveHandler(result, resultResource);
    try {
        analysisResultSaveHandler.saveOrThrow();
    } catch (final SerializationException e) {
        // attempt to save what we can - and then rethrow
        final AnalysisResult safeAnalysisResult = analysisResultSaveHandler.createSafeAnalysisResult();
        if (safeAnalysisResult == null) {
            logger.error("Serialization of result failed without any safe result elements to persist");
        } else {
            final Map<ComponentJob, AnalyzerResult> unsafeResultElements =
                    analysisResultSaveHandler.getUnsafeResultElements();
            logger.error("Serialization of result failed with the following unsafe elements: {}",
                    unsafeResultElements);
            logger.warn("Partial AnalysisResult will be persisted to filename '{}'",
                    resultResource.getQualifiedPath());

            analysisResultSaveHandler.saveWithoutUnsafeResultElements();
        }

        // rethrow the exception regardless
        throw e;
    }
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:26,代码来源:Main.java

示例3: saveOrThrow

import org.apache.commons.lang.SerializationException; //导入依赖的package包/类
private static void saveOrThrow(final AnalysisResult analysisResult, final Resource resource) {
    final SimpleAnalysisResult simpleAnalysisResult;
    if (analysisResult instanceof SimpleAnalysisResult) {
        simpleAnalysisResult = (SimpleAnalysisResult) analysisResult;
    } else {
        simpleAnalysisResult =
                new SimpleAnalysisResult(analysisResult.getResultMap(), analysisResult.getCreationDate());
    }

    final OutputStream out = resource.write();
    try {
        SerializationUtils.serialize(simpleAnalysisResult, out);
    } catch (final SerializationException e) {
        logger.error("Error serializing analysis result: " + analysisResult, e);
        throw e;
    } finally {
        FileHelper.safeClose(out);
    }
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:20,代码来源:AnalysisResultSaveHandler.java

示例4: getUnsafeResultElements

import org.apache.commons.lang.SerializationException; //导入依赖的package包/类
/**
 * Gets a map of unsafe result elements, ie. elements that cannot be saved
 * because serialization fails.
 *
 * @return
 */
public Map<ComponentJob, AnalyzerResult> getUnsafeResultElements() {
    if (_unsafeResultElements == null) {
        _unsafeResultElements = new LinkedHashMap<>();
        final Map<ComponentJob, AnalyzerResult> resultMap = _analysisResult.getResultMap();
        for (final Entry<ComponentJob, AnalyzerResult> entry : resultMap.entrySet()) {
            final AnalyzerResult analyzerResult = entry.getValue();
            try {
                SerializationUtils.serialize(analyzerResult, new NullOutputStream());
            } catch (final SerializationException e) {
                _unsafeResultElements.put(entry.getKey(), analyzerResult);
            }
        }
    }
    return _unsafeResultElements;
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:22,代码来源:AnalysisResultSaveHandler.java

示例5: testMultiget_TranscoderExecption

import org.apache.commons.lang.SerializationException; //导入依赖的package包/类
@Test(expected = ExecutionException.class)
public void testMultiget_TranscoderExecption() throws ExecutionException, InterruptedException, TimeoutException {
  final Transcoder<Serializable> transcoder = new Transcoder<Serializable>() {
    @Override
    public Serializable decode(final byte[] b) {
      throw new SerializationException("QQQQQ YYYYY");
    }

    @Override
    public byte[] encode(final Serializable t) {
      return SerializationUtils.serialize(t);
    }
  };

  final MemcachedClient<Object, Serializable> client = createClient(transcoder);

  client.setAsync("meh", "its here").get();
  client.getBulkAsync(Lists.newArrayList("meh", "bah")).get(1, TimeUnit.MINUTES);
}
 
开发者ID:outbrain,项目名称:ob1k,代码行数:20,代码来源:MemcachedClientTest.java

示例6: deserialize

import org.apache.commons.lang.SerializationException; //导入依赖的package包/类
@Override
public <T> T deserialize(byte[] bytes, Class<T> clazz) throws SerializationException {
    try {
        T message = clazz.newInstance();
        Schema schema = getSchema(clazz);
        ProtostuffIOUtil.mergeFrom(bytes, message, schema);
        return message;
    } catch (Throwable e) {
        throw new SerializationException(e.getMessage(), e);
    }
}
 
开发者ID:justimkiss,项目名称:bee,代码行数:12,代码来源:ProtostuffSerializer.java

示例7: serialize

import org.apache.commons.lang.SerializationException; //导入依赖的package包/类
@Override
public byte[] serialize(Object obj) throws  SerializationException {
    LinkedBuffer buffer = LinkedBuffer.allocate(1024);
    try {
        Schema schema = getSchema(obj.getClass());
        return ProtostuffIOUtil.toByteArray(obj, schema, buffer);
    } catch (Throwable e) {
        throw new SerializationException(e.getMessage(), e);
    } finally {
        buffer.clear();
    }
}
 
开发者ID:justimkiss,项目名称:bee,代码行数:13,代码来源:ProtostuffSerializer.java

示例8: saveAttempt

import org.apache.commons.lang.SerializationException; //导入依赖的package包/类
public boolean saveAttempt() {
    try {
        saveOrThrow();
        return true;
    } catch (final SerializationException e) {
        return false;
    }
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:9,代码来源:AnalysisResultSaveHandler.java

示例9: encode

import org.apache.commons.lang.SerializationException; //导入依赖的package包/类
public String encode(Object object) throws SerializationException {
	if (object == null) {
		return null;
	}
	return new String(Base64.encodeBase64(HessianZipSerializer
			.encode(object)));
}
 
开发者ID:xiyelife,项目名称:jresplus,代码行数:8,代码来源:CookiesEncodeImpl.java

示例10: decode

import org.apache.commons.lang.SerializationException; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public T decode(final byte[] b) {
  final Template<?> template = messagePack.lookup(valueType);

  try {
    final Value value = messagePack.read(b);
    return (T) template.read(new Converter(messagePack, value), null);
  } catch (final IOException e) {
    throw new SerializationException("Failed to decode to type " + valueType.getTypeName(), e);
  }
}
 
开发者ID:outbrain,项目名称:ob1k,代码行数:13,代码来源:MessagePackTranscoder.java

示例11: encode

import org.apache.commons.lang.SerializationException; //导入依赖的package包/类
@Override
public byte[] encode(final T t) {
  try {
    return messagePack.write(t);
  } catch (final IOException e) {
    throw new SerializationException("Failed to encode input " + t.getClass().getSimpleName() + " to type " + valueType.getTypeName(), e);
  }
}
 
开发者ID:outbrain,项目名称:ob1k,代码行数:9,代码来源:MessagePackTranscoder.java

示例12: decode

import org.apache.commons.lang.SerializationException; //导入依赖的package包/类
@Override
public T decode(final byte[] b) {
  try {
    return objectMapper.readValue(b, valueType);
  } catch (final IOException e) {
    throw new SerializationException("Failed to decode to type " + valueType.getSimpleName(), e);
  }
}
 
开发者ID:outbrain,项目名称:ob1k,代码行数:9,代码来源:JsonTranscoder.java

示例13: encode

import org.apache.commons.lang.SerializationException; //导入依赖的package包/类
@Override
public byte[] encode(final T t) {
  try {
    return objectMapper.writeValueAsBytes(t);
  } catch (final JsonProcessingException e) {
    throw new SerializationException("Failed to encode input " + t.getClass().getSimpleName() + " to type " + valueType.getSimpleName(), e);
  }
}
 
开发者ID:outbrain,项目名称:ob1k,代码行数:9,代码来源:JsonTranscoder.java

示例14: fromBytes

import org.apache.commons.lang.SerializationException; //导入依赖的package包/类
@Override
public Optional<Throwable> fromBytes(final byte[] bytes) {
  try {
    return Optional.<Throwable>of((Throwable) SerializationUtils.deserialize(bytes));
  } catch (SerializationException | IllegalArgumentException e) {
    LOG.log(Level.FINE, "Unable to deserialize a Throwable.", e);
    return Optional.empty();
  }
}
 
开发者ID:apache,项目名称:reef,代码行数:10,代码来源:DefaultExceptionCodec.java

示例15: JaxBDeserializer

import org.apache.commons.lang.SerializationException; //导入依赖的package包/类
/**
 * Constructs a JAX-WS deserializer for the specified class.
 *
 * @param clazz Class to deserialize.
 * @throws SerializationException if unable to construct the deserializer.
 */
public JaxBDeserializer(Class<T> clazz) {
  this.clazz = clazz;
  try {
    this.jaxbContext = JAXBContext.newInstance(clazz);
  } catch (JAXBException e) {
    throw new SerializationException(
        String.format("Could not construct deserializer for class: %s.", clazz), e);
  }
}
 
开发者ID:googleads,项目名称:googleads-java-lib,代码行数:16,代码来源:JaxBDeserializer.java


注:本文中的org.apache.commons.lang.SerializationException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。