test_class.file: proxy/src/test/java/com/wavefront/agent/queueing/RetryTaskConverterTest.java
test_class.identifier: RetryTaskConverterTest
test_case.body: @Test
    public void testTaskSerialize() {
      UUID proxyId = UUID.randomUUID();
      LineDelimitedDataSubmissionTask task = new LineDelimitedDataSubmissionTask(null, proxyId,
          new DefaultEntityPropertiesForTesting(), null, "wavefront", ReportableEntityType.POINT,
          "2878", ImmutableList.of("item1", "item2", "item3"), () -> 12345L);
      RetryTaskConverter<LineDelimitedDataSubmissionTask> converter = new RetryTaskConverter<>(
          "2878", RetryTaskConverter.CompressionType.NONE);
  
      assertNull(converter.fromBytes(new byte[] {0, 0, 0}));
      assertNull(converter.fromBytes(new byte[] {'W', 'F', 0}));
      assertNull(converter.fromBytes(new byte[] {'W', 'F', 1}));
      assertNull(converter.fromBytes(new byte[] {'W', 'F', 1, 0}));
    }
test_case.class_method_signature: RetryTaskConverterTest.testTaskSerialize()
test_case.full_signature: @Test public void testTaskSerialize()
test_case.identifier: testTaskSerialize
test_case.invocations: randomUUID of assertNull fromBytes assertNull fromBytes assertNull fromBytes assertNull fromBytes
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testTaskSerialize()
focal_class.declarator: logger = Logger.getLogger(
        RetryTaskConverter.class.getCanonicalName())
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = Logger.getLogger(
        RetryTaskConverter.class.getCanonicalName());
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: TASK_HEADER = new byte[] { 'W', 'F' }
focal_class.modifier: static final
focal_class.original_string: static final byte[] TASK_HEADER = new byte[] { 'W', 'F' };
focal_class.type: byte[]
focal_class.var_name: TASK_HEADER
focal_class.declarator: FORMAT_RAW = 1
focal_class.modifier: static final
focal_class.original_string: static final byte FORMAT_RAW = 1;
focal_class.type: byte
focal_class.var_name: FORMAT_RAW
focal_class.declarator: FORMAT_GZIP = 2
focal_class.modifier: static final
focal_class.original_string: static final byte FORMAT_GZIP = 2;
focal_class.type: byte
focal_class.var_name: FORMAT_GZIP
focal_class.declarator: FORMAT_LZ4 = 3
focal_class.modifier: static final
focal_class.original_string: static final byte FORMAT_LZ4 = 3;
focal_class.type: byte
focal_class.var_name: FORMAT_LZ4
focal_class.declarator: WRAPPED = 4
focal_class.modifier: static final
focal_class.original_string: static final byte WRAPPED = 4;
focal_class.type: byte
focal_class.var_name: WRAPPED
focal_class.declarator: PREFIX = { 'W', 'F', 6, 4 }
focal_class.modifier: static final
focal_class.original_string: static final byte[] PREFIX = { 'W', 'F', 6, 4 };
focal_class.type: byte[]
focal_class.var_name: PREFIX
focal_class.declarator: objectMapper = JsonMapper.builder().
        activateDefaultTyping(LaissezFaireSubTypeValidator.instance).build()
focal_class.modifier: private final
focal_class.original_string: private final ObjectMapper objectMapper = JsonMapper.builder().
        activateDefaultTyping(LaissezFaireSubTypeValidator.instance).build();
focal_class.type: ObjectMapper
focal_class.var_name: objectMapper
focal_class.declarator: compressionType
focal_class.modifier: private final
focal_class.original_string: private final CompressionType compressionType;
focal_class.type: CompressionType
focal_class.var_name: compressionType
focal_class.declarator: errorCounter
focal_class.modifier: private final
focal_class.original_string: private final Counter errorCounter;
focal_class.type: Counter
focal_class.var_name: errorCounter
focal_class.file: proxy/src/main/java/com/wavefront/agent/queueing/RetryTaskConverter.java
focal_class.identifier: RetryTaskConverter
focal_class.interfaces: implements TaskConverter<T>
focal_class.class_method_signature: RetryTaskConverter.RetryTaskConverter(String handle, CompressionType compressionType)
focal_class.full_signature: public  RetryTaskConverter(String handle, CompressionType compressionType)
focal_class.identifier: RetryTaskConverter
focal_class.modifiers: public
focal_class.parameters: (String handle, CompressionType compressionType)
focal_class.signature:  RetryTaskConverter(String handle, CompressionType compressionType)
focal_class.class_method_signature: RetryTaskConverter.fromBytes(@Nonnull byte[] bytes)
focal_class.full_signature: @SuppressWarnings("unchecked") @Nullable @Override public T fromBytes(@Nonnull byte[] bytes)
focal_class.identifier: fromBytes
focal_class.modifiers: @SuppressWarnings("unchecked") @Nullable @Override public
focal_class.parameters: (@Nonnull byte[] bytes)
focal_class.return: T
focal_class.signature: T fromBytes(@Nonnull byte[] bytes)
focal_class.class_method_signature: RetryTaskConverter.serializeToStream(@Nonnull T t, @Nonnull OutputStream bytes)
focal_class.full_signature: @Override public void serializeToStream(@Nonnull T t, @Nonnull OutputStream bytes)
focal_class.identifier: serializeToStream
focal_class.modifiers: @Override public
focal_class.parameters: (@Nonnull T t, @Nonnull OutputStream bytes)
focal_class.return: void
focal_class.signature: void serializeToStream(@Nonnull T t, @Nonnull OutputStream bytes)
focal_class.class_method_signature: RetryTaskConverter.getWeight(@Nonnull byte[] bytes)
focal_class.full_signature: @Nullable @Override public Integer getWeight(@Nonnull byte[] bytes)
focal_class.identifier: getWeight
focal_class.modifiers: @Nullable @Override public
focal_class.parameters: (@Nonnull byte[] bytes)
focal_class.return: Integer
focal_class.signature: Integer getWeight(@Nonnull byte[] bytes)
focal_method.body: @SuppressWarnings("unchecked")
    @Nullable
    @Override
    public T fromBytes(@Nonnull byte[] bytes) {
      ByteArrayInputStream input = new ByteArrayInputStream(bytes);
      int len = TASK_HEADER.length;
      byte[] prefix = new byte[len];
      if (input.read(prefix, 0, len) == len && Arrays.equals(prefix, TASK_HEADER)) {
        int bytesToRead = input.read();
        if (bytesToRead > 0) {
          byte[] header = new byte[bytesToRead];
          if (input.read(header, 0, bytesToRead) == bytesToRead) {
            InputStream stream = null;
            byte compression = header[0] == WRAPPED && bytesToRead > 1 ? header[1] : header[0];
            try {
              switch (compression) {
                case FORMAT_LZ4:
                  stream = new LZ4BlockInputStream(input);
                  break;
                case FORMAT_GZIP:
                  stream = new GZIPInputStream(input);
                  break;
                case FORMAT_RAW:
                  stream = input;
                  break;
                default:
                  logger.warning("Unable to restore persisted task - unsupported data format " +
                      "header detected: " + Arrays.toString(header));
                  return null;
              }
              return (T) objectMapper.readValue(stream, DataSubmissionTask.class);
            } catch (Throwable t) {
              logger.warning("Unable to restore persisted task: " + t);
            } finally {
              IOUtils.closeQuietly(stream);
            }
          } else {
            logger.warning("Unable to restore persisted task - corrupted header, ignoring");
          }
        } else {
          logger.warning("Unable to restore persisted task - missing header, ignoring");
        }
      } else {
        logger.warning("Unable to restore persisted task - invalid or missing header, ignoring");
      }
      errorCounter.inc();
      return null;
    }
focal_method.class_method_signature: RetryTaskConverter.fromBytes(@Nonnull byte[] bytes)
focal_method.full_signature: @SuppressWarnings("unchecked") @Nullable @Override public T fromBytes(@Nonnull byte[] bytes)
focal_method.identifier: fromBytes
focal_method.invocations: read equals read read warning toString readValue warning closeQuietly warning warning warning inc
focal_method.modifiers: @SuppressWarnings("unchecked") @Nullable @Override public
focal_method.parameters: (@Nonnull byte[] bytes)
focal_method.return: T
focal_method.signature: T fromBytes(@Nonnull byte[] bytes)