WingtipsToZipkinSpanConverterDefaultImpl implements WingtipsToZipkinSpanConverter { protected Long attemptToConvertToLong(final String id) { if (id == null) { return null; } int numDigits = 0; boolean firstCharIsDash = false; for (int i = 0; i < id.length(); i++) { char nextChar = id.charAt(i); boolean isDigit = (nextChar >= '0' && nextChar <= '9'); if (isDigit) { numDigits++; } else { if (i == 0 && nextChar == '-') { firstCharIsDash = true; } else { return null; } } } if (!isWithinRangeOfJavaLongMinAndMax(id, numDigits, firstCharIsDash)) { return null; } try { return Long.parseLong(id); } catch (final NumberFormatException nfe) { logger.warn( "Found digits-based-ID that reached Long.parseLong(id) and failed. " + "This should never happen - please report this to the Wingtips maintainers. " + "invalid_id={}, NumberFormatException={}", id, nfe.toString() ); return null; } } WingtipsToZipkinSpanConverterDefaultImpl();  WingtipsToZipkinSpanConverterDefaultImpl(boolean enableIdSanitization); @Override zipkin2.Span convertWingtipsSpanToZipkinSpan(Span wingtipsSpan, Endpoint zipkinEndpoint);  }
@DataProvider(value = { "0 | true", "1 | true", "-1 | true", "42 | true", "-42 | true", "2147483648 | true", "-2147483649 | true", "9199999999999999999 | true", "-9199999999999999999 | true", "9223372036854775807 | true", "-9223372036854775808 | true", "9223372036854775808 | false", "-9223372036854775809 | false", "9300000000000000000 | false", "-9300000000000000000 | false", "10000000000000000000 | false", "-10000000000000000000 | false", "42blue42 | false", "42f | false", "4-2 | false", "42- | false", "null | false" }, splitBy = "\\|") @Test public void attemptToConvertToLong_works_as_expected(String longAsString, boolean expectValidLongResult) { Long expectedResult = (expectValidLongResult) ? Long.parseLong(longAsString) : null; Long result = impl.attemptToConvertToLong(longAsString); assertThat(result).isEqualTo(expectedResult); }