@Override public boolean asyncDecode(CachedData d) { if ((d.getFlags() & COMPRESSED) != 0 || (d.getFlags() & SERIALIZED) != 0) { return true; } return super.asyncDecode(d); }
/** * Get the object represented by the given serialized bytes. */ protected Object deserialize(byte[] in) { Object rv=null; try { if(in != null) { ByteArrayInputStream bis=new ByteArrayInputStream(in); ObjectInputStream is=new ObjectInputStream(bis); rv=is.readObject(); is.close(); bis.close(); } } catch(IOException e) { getLogger().warn("Caught IOException decoding %d bytes of data", in.length, e); } catch (ClassNotFoundException e) { getLogger().warn("Caught CNFE decoding %d bytes of data", in.length, e); } return rv; }
/** * Get the object represented by the given serialized bytes. */ protected Object deserialize(byte[] in) { Object rv = null; try { if (in != null) { ByteArrayInputStream bis = new ByteArrayInputStream(in); ObjectInputStream is = new ObjectInputStream(bis); rv = is.readObject(); is.close(); bis.close(); } } catch (IOException e) { getLogger().warn("Caught IOException decoding %d bytes of data", in == null ? 0 : in.length, e); } catch (ClassNotFoundException e) { getLogger().warn("Caught CNFE decoding %d bytes of data", in == null ? 0 : in.length, e); } return rv; }
@Override public boolean asyncDecode(CachedData d) { if ((d.getFlags() & COMPRESSED) != 0 || (d.getFlags() & SERIALIZED) != 0) { return true; } return super.asyncDecode(d); }
/** * Decompress the given array of bytes. * * @return null if the bytes cannot be decompressed */ protected byte[] decompress(byte[] in) { ByteArrayOutputStream bos=null; if(in != null) { ByteArrayInputStream bis=new ByteArrayInputStream(in); bos=new ByteArrayOutputStream(); GZIPInputStream gis; try { gis = new GZIPInputStream(bis); byte[] buf=new byte[8192]; int r=-1; while((r=gis.read(buf)) > 0) { bos.write(buf, 0, r); } } catch (IOException e) { getLogger().warn("Failed to decompress data", e); bos = null; } } return bos == null ? null : bos.toByteArray(); }
@Override public boolean asyncDecode(CachedData d) { if ((d.getFlags() & COMPRESSED) != 0 || (d.getFlags() & SERIALIZED) != 0) { return true; } return super.asyncDecode(d); }
/** * Get the object represented by the given serialized bytes. */ protected Object deserialize(byte[] in) { Object rv=null; try { if(in != null) { ByteArrayInputStream bis=new ByteArrayInputStream(in); ObjectInputStream is=new ObjectInputStream(bis); rv=is.readObject(); is.close(); bis.close(); } } catch(IOException e) { getLogger().warn("Caught IOException decoding %d bytes of data", in == null ? 0 : in.length, e); } catch (ClassNotFoundException e) { getLogger().warn("Caught CNFE decoding %d bytes of data", in == null ? 0 : in.length, e); } return rv; }
@Override public boolean asyncDecode(CachedData d) { if ((d.getFlags() & COMPRESSED) != 0 || (d.getFlags() & SERIALIZED) != 0) { return true; } return super.asyncDecode(d); }
/** * Decompress the given array of bytes. * * @return null if the bytes cannot be decompressed */ protected byte[] decompress(byte[] in) { ByteArrayOutputStream bos=null; if(in != null) { ByteArrayInputStream bis=new ByteArrayInputStream(in); bos=new ByteArrayOutputStream(); GZIPInputStream gis; try { gis = new GZIPInputStream(bis); byte[] buf=new byte[8192]; int r=-1; while((r=gis.read(buf)) > 0) { bos.write(buf, 0, r); } } catch (IOException e) { getLogger().warn("Failed to decompress data", e); bos = null; } } return bos == null ? null : bos.toByteArray(); }
@Override public boolean asyncDecode(CachedData d) { if((d.getFlags() & COMPRESSED) != 0 || (d.getFlags() & SERIALIZED) != 0 ) { return true; } return super.asyncDecode(d); }
/** * Decompress the given array of bytes. * * @return null if the bytes cannot be decompressed */ protected byte[] decompress(byte[] in) { ByteArrayOutputStream bos = null; if (in != null) { ByteArrayInputStream bis = new ByteArrayInputStream(in); bos = new ByteArrayOutputStream(); GZIPInputStream gis; try { gis = new GZIPInputStream(bis); byte[] buf = new byte[8192]; int r = -1; while ((r = gis.read(buf)) > 0) { bos.write(buf, 0, r); } } catch (IOException e) { getLogger().warn("Failed to decompress data", e); bos = null; } } return bos == null ? null : bos.toByteArray(); }
@Override public boolean asyncDecode(CachedData d) { if((d.getFlags() & COMPRESSED) != 0 || (d.getFlags() & SERIALIZED) != 0 ) { return true; } return super.asyncDecode(d); }
/** * Compress the given array of bytes. */ protected byte[] compress(byte[] in) { if (in == null) { throw new NullPointerException("Can't compress null"); } ByteArrayOutputStream bos = new ByteArrayOutputStream(); GZIPOutputStream gz = null; try { gz = new GZIPOutputStream(bos); gz.write(in); } catch (IOException e) { throw new RuntimeException("IO exception compressing data", e); } finally { CloseUtil.close(gz); CloseUtil.close(bos); } byte[] rv = bos.toByteArray(); getLogger().debug("Compressed %d bytes to %d", in.length, rv.length); return rv; }
/** * Compress the given array of bytes. */ protected byte[] compress(byte[] in) { if(in == null) { throw new NullPointerException("Can't compress null"); } ByteArrayOutputStream bos=new ByteArrayOutputStream(); GZIPOutputStream gz=null; try { gz = new GZIPOutputStream(bos); gz.write(in); } catch (IOException e) { throw new RuntimeException("IO exception compressing data", e); } finally { CloseUtil.close(gz); CloseUtil.close(bos); } byte[] rv=bos.toByteArray(); getLogger().debug("Compressed %d bytes to %d", in.length, rv.length); return rv; }
/** * Compress the given array of bytes. */ protected byte[] compress(byte[] in) { if (in == null) { throw new NullPointerException("Can't compress null"); } ByteArrayOutputStream bos = new ByteArrayOutputStream(); GZIPOutputStream gz = null; try { gz = new GZIPOutputStream(bos); gz.write(in); } catch (IOException e) { throw new RuntimeException("IO exception compressing data", e); } finally { CloseUtil.close(gz); CloseUtil.close(bos); } byte[] rv = bos.toByteArray(); getLogger().debug("Compressed %d bytes to %d", in.length, rv.length); return rv; }
/** * Compress the given array of bytes. */ protected byte[] compress(byte[] in) { if(in == null) { throw new NullPointerException("Can't compress null"); } ByteArrayOutputStream bos=new ByteArrayOutputStream(); GZIPOutputStream gz=null; try { gz = new GZIPOutputStream(bos); gz.write(in); } catch (IOException e) { throw new RuntimeException("IO exception compressing data", e); } finally { CloseUtil.close(gz); CloseUtil.close(bos); } byte[] rv=bos.toByteArray(); getLogger().debug("Compressed %d bytes to %d", in.length, rv.length); return rv; }
/** * Compress the given array of bytes. */ protected byte[] compress(byte[] in) { if (in == null) { throw new NullPointerException("Can't compress null"); } ByteArrayOutputStream bos = new ByteArrayOutputStream(); GZIPOutputStream gz = null; try { gz = new GZIPOutputStream(bos); gz.write(in); } catch (IOException e) { throw new RuntimeException("IO exception compressing data", e); } finally { CloseUtil.close(gz); CloseUtil.close(bos); } byte[] rv = bos.toByteArray(); getLogger().debug("Compressed %d bytes to %d", in.length, rv.length); return rv; }
/** * Get the object represented by the given serialized bytes. */ protected Object deserialize(byte[] in) { Object rv=null; ByteArrayInputStream bis = null; ObjectInputStream is = null; try { if(in != null) { bis=new ByteArrayInputStream(in); is=new ObjectInputStream(bis); rv=is.readObject(); is.close(); bis.close(); } } catch (IOException e) { getLogger().warn("Caught IOException decoding %d bytes of data", in == null ? 0 : in.length, e); } catch (ClassNotFoundException e) { getLogger().warn("Caught CNFE decoding %d bytes of data", in == null ? 0 : in.length, e); } finally { CloseUtil.close(is); CloseUtil.close(bis); } return rv; }
/** * Compress the given array of bytes. */ protected byte[] compress(byte[] in) { if (in == null) { throw new NullPointerException("Can't compress null"); } ByteArrayOutputStream bos = new ByteArrayOutputStream(); GZIPOutputStream gz = null; try { gz = new GZIPOutputStream(bos); gz.write(in); } catch (IOException e) { throw new RuntimeException("IO exception compressing data", e); } finally { CloseUtil.close(gz); CloseUtil.close(bos); } byte[] rv = bos.toByteArray(); getLogger().debug("Compressed %d bytes to %d", in.length, rv.length); return rv; }
/** * Get the object represented by the given serialized bytes. */ protected Object deserialize(byte[] in) { Object rv=null; ByteArrayInputStream bis = null; ObjectInputStream is = null; try { if(in != null) { bis=new ByteArrayInputStream(in); is=new ObjectInputStream(bis); rv=is.readObject(); is.close(); bis.close(); } } catch (IOException e) { getLogger().warn("Caught IOException decoding %d bytes of data", in == null ? 0 : in.length, e); } catch (ClassNotFoundException e) { getLogger().warn("Caught CNFE decoding %d bytes of data", in == null ? 0 : in.length, e); } finally { CloseUtil.close(is); CloseUtil.close(bis); } return rv; }