auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public ElasticsearchTableDescription getTable(String schemaName, String tableName) { requireNonNull(schemaName, "schemaName is null"); requireNonNull(tableName, "tableName is null"); try { for (Map.Entry<SchemaTableName, ElasticsearchTableDescription> entry : tableDescriptions.entrySet()) { buildColumns(entry.getKey(), entry.getValue()); } } catch (Exception e) { <START> throw new PrestoException(GENERIC_INTERNAL_ERROR, e.getMessage()); <END> } return tableDescriptions.get(new SchemaTableName(schemaName, tableName)); }</code><technical_language>Instead of relying generic error codes, define a new set of codes specific elastic search connector (see HiveErrorCode, KafkaErrorCode, etc. for examples). Also, instead of a catch statement throw codes specific exceptions, more useful user error occurs</technical_language>

Target:
public ElasticsearchTableDescription getTable(String schemaName, String tableName) { requireNonNull(schemaName, "schemaName is null"); requireNonNull(tableName, "tableName is null"); for (Entry<SchemaTableName, ElasticsearchTableDescription> entry : tableDescriptions.entrySet()) { ElasticsearchTableDescription table = entry.getValue(); if (table.getColumns() == null) { buildColumns(table); } if (!table.isMetadataSet()) { table.setColumnsMetadata(table.getColumns().stream() .map(ElasticsearchColumnMetadata::new) .collect(Collectors.toList())); } } return tableDescriptions.get(new SchemaTableName(schemaName, tableName)); }
Source:
<code>public static boolean isSvgImage(String path) { <START> return path.toUpperCase().endsWith(ImageFileFormat.SVG.getName()) || path.toUpperCase().endsWith(ImageFileFormat.SVGZ.getName()); <END> }</code><technical_language>a variable for path.toUpperCase() instead of potentially called twice</technical_language>

Target:
public static boolean isSvgImage(String path) { String pathToUpperCase = path.toUpperCase(); return pathToUpperCase.endsWith(ImageFileFormat.SVG.getName()) || pathToUpperCase.endsWith(ImageFileFormat.SVGZ.getName()); }
Source:
<code>private String validateAndGetPayloadUrl(final ReleaseWebHookResource parameters) { String payloadUrl = parameters.getPayloadUrl(); if (StringUtils.isBlank(payloadUrl)) { <START> throw new InvalidParameterException("pyaloadUrl is empty"); <END> } final URI uri; try { uri = new URI(payloadUrl); } catch (final URISyntaxException e) { throw new InvalidParameterException("Malformed Payload URL " + e.getMessage()); } final String hostName = uri.getHost(); if (StringUtils.isBlank(hostName)) { throw new InvalidParameterException("Malformed Payload URL"); } return StringUtils.stripEnd(StringUtils.trim(payloadUrl), "/"); }</code><technical_language>fix typo</technical_language>

Target:
private String validateAndGetPayloadUrl(final ReleaseWebHookResource parameters) { String payloadUrl = parameters.getPayloadUrl(); if (StringUtils.isBlank(payloadUrl)) { throw new InvalidParameterException("PayloadUrl is empty"); } final URI uri; try { uri = new URI(payloadUrl); } catch (final URISyntaxException e) { throw new InvalidParameterException("Malformed Payload URL " + e.getMessage()); } final String hostName = uri.getHost(); if (StringUtils.isBlank(hostName)) { throw new InvalidParameterException("Payload URL is empty"); } return StringUtils.stripEnd(StringUtils.trim(payloadUrl), "/"); }
Source:
<code>public int getPublishSizeLimit() { <START> return 32 * 1024 * 1024; <END> }</code><technical_language>I configurable sense</technical_language>

Target:
public int getPublishSizeLimit() { return publisSizeLimit; }
Source:
<code><START> public void run() { <END> if (fViewer == null || fInlinedAnnotationSupport == null || fCodeMiningProviders == null || fCodeMiningProviders.size() == 0 || fViewer.getAnnotationModel() == null) { return; } cancel(); fMonitor= new CancellationExceptionMonitor(); update(fMonitor); }</code><technical_language>call updateCodeMinings() instead</technical_language>

Target:
public void run() { if (fViewer == null || fInlinedAnnotationSupport == null || fCodeMiningProviders == null || fCodeMiningProviders.size() == 0 || fViewer.getAnnotationModel() == null) { return; } cancel(); updateCodeMinings(); }
Source:
<code>public List<String> getPartitionDimensions() { <START> return null; <END> }</code><technical_language>feel making this passed a json property in HashedPartitionsSpec add docs, people</technical_language>

Target:
public List<String> getPartitionDimensions() { return partitionDimensions; }
Source:
<code>public ConfigurationBuilder getDefaultConfigurationBuilder() { <START> return globalConfigurationBuilder.defaultCacheName().map(namedConfigurationBuilders::get).orElse(null); <END> }</code><technical_language>Technically this is another lambda out of scope of this PR imo</technical_language>

Target:
public ConfigurationBuilder getDefaultConfigurationBuilder() { if (globalConfigurationBuilder.defaultCacheName().isPresent()) { return namedConfigurationBuilders.get(globalConfigurationBuilder.defaultCacheName().get()); } else { return null; } }
Source:
<code>public static QueriesCommandBase<?> createQueryCommand(VdcQueryType query, VdcQueryParametersBase parameters, EngineContext engineContext) { Class<?> type = null; try { type = getCommandClass(query.name(), QueryPrefix); Constructor<?> info = engineContext != null ? findCommandConstructor(type, parameters.getClass(), engineContext.getClass()) : <START> findCommandConstructor(type, parameters.getClass()); <END> return (QueriesCommandBase<?>) info.newInstance(parameters); } catch (Exception e) { log.errorFormat("Command Factory: Failed to create command {0} using reflection\n. {1}", type, e); throw new RuntimeException(e); } }</code><technical_language>please remove extra space</technical_language>

Target:
public static QueriesCommandBase<?> createQueryCommand(VdcQueryType query, VdcQueryParametersBase parameters, EngineContext engineContext) { Class<?> type = null; try { type = getCommandClass(query.name(), QueryPrefix); QueriesCommandBase<?> result = null; if (engineContext == null) { result = (QueriesCommandBase<?>) findCommandConstructor(type, parameters.getClass()).newInstance(parameters); } else { result = (QueriesCommandBase<?>) findCommandConstructor(type, parameters.getClass(), EngineContext.class).newInstance(parameters, engineContext); } return result; } catch (Exception e) { log.errorFormat("Command Factory: Failed to create command {0} using reflection\n. {1}", type, e); throw new RuntimeException(e); } }
Source:
<code><START> public void setUp(DBMSType dbmsType, DBMSConnection dbmsConnection, DBMSProcessor dbmsProcessor) throws SQLException, DatabaseNotSupportedException, InvalidDBMSConnectionPropertiesException { <END> clientContextA = new BibDatabaseContext(new Defaults(BibDatabaseMode.BIBTEX)); DBMSSynchronizer synchronizerA = new DBMSSynchronizer(clientContextA, ',', pattern, new DummyFileUpdateMonitor()); clientContextA.convertToSharedDatabase(synchronizerA); clientContextA.getDBMSSynchronizer().openSharedDatabase(dbmsConnection); clientContextB = new BibDatabaseContext(new Defaults(BibDatabaseMode.BIBTEX)); DBMSSynchronizer synchronizerB = new DBMSSynchronizer(clientContextA, ',', pattern, new DummyFileUpdateMonitor()); clientContextB.convertToSharedDatabase(synchronizerB); clientContextB.getDBMSSynchronizer().openSharedDatabase(dbmsConnection); eventListenerB = new SynchronizationTestEventListener(); clientContextB.getDBMSSynchronizer().registerListener(eventListenerB); }</code><technical_language>double chcking (but understand implications of Tobias' explanation), I bet test database system avaiable</technical_language>

Target:
public void setUp(DBMSType dbmsType, DBMSConnection dbmsConnection, DBMSProcessor dbmsProcessor) throws Exception { clientContextA = new BibDatabaseContext(new Defaults(BibDatabaseMode.BIBTEX)); DBMSSynchronizer synchronizerA = new DBMSSynchronizer(clientContextA, ',', pattern, new DummyFileUpdateMonitor()); clientContextA.convertToSharedDatabase(synchronizerA); clientContextA.getDBMSSynchronizer().openSharedDatabase(dbmsConnection); clientContextB = new BibDatabaseContext(new Defaults(BibDatabaseMode.BIBTEX)); DBMSSynchronizer synchronizerB = new DBMSSynchronizer(clientContextA, ',', pattern, new DummyFileUpdateMonitor()); clientContextB.convertToSharedDatabase(synchronizerB); clientContextB.getDBMSSynchronizer().openSharedDatabase(dbmsConnection); eventListenerB = new SynchronizationTestEventListener(); clientContextB.getDBMSSynchronizer().registerListener(eventListenerB); }
Source:
<code>private boolean validateMixPath(){ String mixPath = myMixPathSelector.getText(); File mix = new File(mixPath); if (!mix.exists()) { return false; } if (!mix.canExecute()) { String reason = mix.getPath() + "is not executable."; LOGGER.warn("Can't detect Mix version: " + reason); return false; } File exeFile = mix.getAbsoluteFile(); String exePath = exeFile.getPath(); String workDir = exeFile.getParent(); ProcessOutput output = null; boolean valid = false; for (String[] arguments : MIX_ARGUMENTS_ARRAY) { try { output = ElixirSystemUtil.getProcessOutput(3000, workDir, exePath, arguments); } catch (ExecutionException executionException) { LOGGER.warn(executionException); } if (output != null) { String transformedStdout = transformStdoutLine(output, STDOUT_LINE_TRANSFORMER); if (transformedStdout != null) { myMixVersionText.setText(transformedStdout); String versionString = transformedStdout.replaceAll("^[^0-9]*", ""); <START> supportsFormatterOptionCheckBox.setSelected(compareVersions(versionString, "1.4") >= 0); <END> valid = true; break; } else { String stderr = output.getStderr(); StringBuilder text = new StringBuilder("N/A"); if (StringUtil.isNotEmpty(stderr)) { text.append(": Error: ").append(stderr); } myMixVersionText.setText(text.toString()); } } } return valid; }</code><technical_language>version comparison methods constructing ElixirSdkRelease. Add org.elixir_lang.sdk.ElixirSdkRelease: public static final ElixirSdkRelease V_1_4 = new ElixirSdkRelease("1", "4", null, null, null); compare versionString: elixirSdkRelease = ElixirSdkRelease.from_string(version_string); supportsFormatterOptionCheckBox.setSelected(elixirSdkRelease.compareTo(ElixirSdkRelease.V_1_4) >= 0);</technical_language>

Target:
private boolean validateMixPath(){ String mixPath = myMixPathSelector.getText(); File mix = new File(mixPath); if (!mix.exists()) { return false; } if (!mix.canExecute()) { String reason = mix.getPath() + "is not executable."; LOGGER.warn("Can't detect Mix version: " + reason); return false; } File exeFile = mix.getAbsoluteFile(); String exePath = exeFile.getPath(); String workDir = exeFile.getParent(); ProcessOutput output = null; boolean valid = false; for (String[] arguments : MIX_ARGUMENTS_ARRAY) { try { output = ElixirSystemUtil.getProcessOutput(3000, workDir, exePath, arguments); } catch (ExecutionException executionException) { LOGGER.warn(executionException); } if (output != null) { String transformedStdout = transformStdoutLine(output, STDOUT_LINE_TRANSFORMER); if (transformedStdout != null) { myMixVersionText.setText(transformedStdout); String versionString = transformedStdout.replaceAll("^[^0-9]*", ""); ElixirSdkRelease elixirSdkRelease = ElixirSdkRelease.fromString(versionString); if (elixirSdkRelease != null) { supportsFormatterOptionCheckBox.setSelected(elixirSdkRelease.compareTo(ElixirSdkRelease.V_1_4) >= 0); } valid = true; break; } else { String stderr = output.getStderr(); StringBuilder text = new StringBuilder("N/A"); if (StringUtil.isNotEmpty(stderr)) { text.append(": Error: ").append(stderr); } myMixVersionText.setText(text.toString()); } } } return valid; }
Source:
<code>public static KeyStore loadKeyStore(final Supplier<Provider[]> providers, final String providerName, FileInputStream is, String filename, char[] password) throws IOException { DataInputStream dis = new ResetableDataFileInputStream(is); int firstInt = dis.readInt(); dis.reset(); KeyStore result = null; try { if (firstInt == JKS_MAGIC) { result = tryLoadKeystore(providers, providerName, dis, password, JKS); } else if (firstInt == JCEKS_MAGIC) { result = tryLoadKeystore(providers, providerName, dis, password, JCEKS); } else if (firstInt == VERSION_1 || firstInt == VERSION_2) { dis.reset(); dis.skip(32); byte firstElementType = dis.readByte(); dis.reset(); if (firstElementType <= 5) { <START> result = tryLoadKeystore(providers, providerName, dis, password, BKS, UBER); <END> } else { result = tryLoadKeystore(providers, providerName, dis, password, UBER, BKS); } } else if (firstInt == VERSION_0) { result = tryLoadKeystore(providers, providerName, dis, password, UBER); } else if ((firstInt & 0xff000000) == SEQUENCE) { String[] parts = filename.split("\\."); String extension = parts[parts.length - 1]; if (extension.startsWith("b") || extension.startsWith("B")) { result = tryLoadKeystore(providers, providerName, dis, password, BCFKS, PKCS12); } else { result = tryLoadKeystore(providers, providerName, dis, password, PKCS12, BCFKS); } } } catch (Exception e) { e.printStackTrace(); } return result; }</code><technical_language>keystore types tried</technical_language>

Target:
public static KeyStore loadKeyStore(final Supplier<Provider[]> providers, final String providerName, FileInputStream is, String filename, char[] password) throws IOException, KeyStoreException{ DataInputStream dis = new ResetableDataFileInputStream(is); int firstInt = dis.readInt(); dis.reset(); KeyStore result = null; if (firstInt == JKS_MAGIC) { result = tryLoadKeystore(providers, providerName, dis, password, JKS); } else if (firstInt == JCEKS_MAGIC) { result = tryLoadKeystore(providers, providerName, dis, password, JCEKS); } else if (firstInt == VERSION_1 || firstInt == VERSION_2) { dis.reset(); dis.skip(32); byte firstElementType = dis.readByte(); dis.reset(); if (firstElementType <= 5) { result = tryLoadKeystore(providers, providerName, dis, password, BKS, UBER); } else { result = tryLoadKeystore(providers, providerName, dis, password, UBER, BKS); } } else if (firstInt == VERSION_0) { result = tryLoadKeystore(providers, providerName, dis, password, UBER); } else if ((firstInt & 0xff000000) == SEQUENCE) { String[] parts = filename.split("\\."); String extension = parts[parts.length - 1]; if (extension.startsWith("b") || extension.startsWith("B")) { result = tryLoadKeystore(providers, providerName, dis, password, BCFKS, PKCS12); } else { result = tryLoadKeystore(providers, providerName, dis, password, PKCS12, BCFKS); } } if (result == null) { throw log.keyStoreTypeNotDetected(); } return result; }
Source:
<code>public void withJwkSetUriWhenUsingCustomTypeHeaderThenRefuseOmittedType() throws Exception { <START> RestOperations restOperations = mock(RestOperations.class); <END> when(restOperations.exchange(any(RequestEntity.class), eq(String.class))) .thenReturn(new ResponseEntity<>(JWK_SET, HttpStatus.OK)); NimbusJwtDecoder jwtDecoder = withJwkSetUri(JWK_SET_URI) .restOperations(restOperations) .jwtProcessorCustomizer(p -> p.setJWSTypeVerifier((type, context) -> { if (type == null) throw new BadJWTException("Illegal token type: null"); })) .build(); assertThatCode(() -> jwtDecoder.decode(SIGNED_JWT)) .isInstanceOf(JwtException.class) .hasMessageContaining("An error occurred while attempting to decode the Jwt: Illegal token type: null"); }</code><technical_language>I this is fine. Note major goal of a test this is customization is used. Mockito fine in this case, too; call verify end of test</technical_language>

Target:
public void withJwkSetUriWhenUsingCustomTypeHeaderThenRefuseOmittedType() throws Exception { RestOperations restOperations = mock(RestOperations.class); when(restOperations.exchange(any(RequestEntity.class), eq(String.class))) .thenReturn(new ResponseEntity<>(JWK_SET, HttpStatus.OK)); NimbusJwtDecoder jwtDecoder = withJwkSetUri(JWK_SET_URI) .restOperations(restOperations) .jwtProcessorCustomizer(p -> p.setJWSTypeVerifier(new DefaultJOSEObjectTypeVerifier<>(new JOSEObjectType("JWS")))) .build(); assertThatCode(() -> jwtDecoder.decode(SIGNED_JWT)) .isInstanceOf(BadJwtException.class) .hasMessageContaining("An error occurred while attempting to decode the Jwt: Required JOSE header \"typ\" (type) parameter is missing"); }
Source:
<code>private void animateAddImpl(final ViewHolder holder) { final View view = holder.itemView; if (view instanceof ProgressCardView) { view.setAlpha(1); <START> view.setTranslationY(0f); <END> dispatchAddFinished(holder); mAddAnimations.remove(holder); return; } final ViewPropertyAnimator animation = view.animate(); mAddAnimations.add(holder); animation.alpha(1).translationY(0).setDuration(getAddDuration()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { dispatchAddStarting(holder); } @Override public void onAnimationCancel(Animator animator) { view.setTranslationY(0f); } @Override public void onAnimationEnd(Animator animator) { animation.setListener(null); dispatchAddFinished(holder); mAddAnimations.remove(holder); dispatchFinishedWhenDone(); } }).start(); }</code><technical_language>change 0f 0 other setTranslationY setTranslationX is 0</technical_language>

Target:
private void animateAddImpl(final ViewHolder holder) { final View view = holder.itemView; if (view instanceof ProgressCardView) { view.setAlpha(1); view.setTranslationY(0); dispatchAddFinished(holder); mAddAnimations.remove(holder); return; } final ViewPropertyAnimator animation = view.animate(); mAddAnimations.add(holder); animation.alpha(1).translationY(0).setDuration(getAddDuration()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { dispatchAddStarting(holder); } @Override public void onAnimationCancel(Animator animator) { view.setTranslationY(0); } @Override public void onAnimationEnd(Animator animator) { animation.setListener(null); dispatchAddFinished(holder); mAddAnimations.remove(holder); dispatchFinishedWhenDone(); } }).start(); }
Source:
<code>private Image findImageWithId(Set<? extends Image> images) { Optional<? extends Image> image = tryFind(images, idPredicate); if (image.isPresent()) { return image.get(); } <START> logger.warn("Image %s not found in the image cache. Trying to get it from the provider...", imageId); <END> Image imageFromProvider = getImageStrategy.getImage(imageId); if (imageFromProvider == null) { throwNoSuchElementExceptionAfterLoggingImageIds(format("%s not found", idPredicate), images); } this.images.registerImage(imageFromProvider); return imageFromProvider; }</code><technical_language>needs another log message image fetched confirming fetched cached. If I message in a log, error "Trying..." succeeds? move log message image fetch change message in tense. e.g. ""Image %s in image cache. Image fetch provider cached in jclouds." Also, this a debug statement? unexpected behaviour. sure. I way</technical_language>

Target:
private Image findImageWithId(Set<? extends Image> images) { Optional<? extends Image> image = tryFind(images, idPredicate); if (image.isPresent()) { return image.get(); } logger.info("Image %s not found in the image cache. Trying to get it from the provider...", imageId); Image imageFromProvider = getImageStrategy.getImage(imageId); if (imageFromProvider == null) { throwNoSuchElementExceptionAfterLoggingImageIds(format("%s not found", idPredicate), images); } this.images.registerImage(imageFromProvider); return imageFromProvider; }
Source:
<code>public void testSetEventDataForPoolSetsEventDataJson() { Pool pool = mock(Pool.class); eventBuilder = new EventBuilder(factory, Event.Target.POOL, Event.Type.CREATED); when(pool.getSubscriptionId()).thenReturn("test-subscription-id"); String expectedEventData = "{\"subscriptionId\": \"test-subscription-id\"}"; Event event = eventBuilder.setEventData(pool).buildEvent(); assertEquals("The expected event data should have been" + <START> expectedEventData + ", but they weren't", expectedEventData, event.getEventData()); <END> }</code><technical_language>description string is nice here, need include expected in it. a failure, include expected actual values in output itself</technical_language>

Target:
public void testSetEventDataForPoolSetsEventDataJson() { Pool pool = mock(Pool.class); eventBuilder = new EventBuilder(factory, Event.Target.POOL, Event.Type.CREATED); when(pool.getSubscriptionId()).thenReturn("test-subscription-id"); String expectedEventData = "{\"subscriptionId\":\"test-subscription-id\"}"; Event event = eventBuilder.setEventData(pool).buildEvent(); assertEquals(expectedEventData, event.getEventData()); }
Source:
<code>private void createOtherSystemTables(PhoenixConnection metaConnection, HBaseAdmin hbaseAdmin) throws SQLException, IOException { try { nSequenceSaltBuckets = ConnectionQueryServicesImpl.this.props.getInt( QueryServices.SEQUENCE_SALT_BUCKETS_ATTRIB, QueryServicesOptions.DEFAULT_SEQUENCE_TABLE_SALT_BUCKETS); metaConnection.createStatement().execute(getSystemSequenceTableDDL(nSequenceSaltBuckets)); } catch (TableAlreadyExistsException e) { nSequenceSaltBuckets = getSaltBuckets(e); } try { metaConnection.createStatement().execute(QueryConstants.CREATE_STATS_TABLE_METADATA); } catch (TableAlreadyExistsException ignore) try { metaConnection.createStatement().execute(getFunctionTableDDL()); } catch (TableAlreadyExistsException ignore) try { metaConnection.createStatement().execute(getLogTableDDL()); } catch (TableAlreadyExistsException ignore) try { metaConnection.createStatement().executeUpdate(getChildLinkDDL()); } catch (TableAlreadyExistsException e) try { metaConnection.createStatement().executeUpdate(getMutexDDL()); } catch (TableAlreadyExistsException e) try { <START> createSysMutexTableIfNotExists(hbaseAdmin); <END> } catch (IOException exception) { logger.error("Failed to created SYSMUTEX table. Upgrade or migration is not possible without it. Please retry."); throw exception; } }</code><technical_language>Do need this part of code</technical_language>

Target:
private void createOtherSystemTables(PhoenixConnection metaConnection, HBaseAdmin hbaseAdmin) throws SQLException, IOException { try { nSequenceSaltBuckets = ConnectionQueryServicesImpl.this.props.getInt( QueryServices.SEQUENCE_SALT_BUCKETS_ATTRIB, QueryServicesOptions.DEFAULT_SEQUENCE_TABLE_SALT_BUCKETS); metaConnection.createStatement().execute(getSystemSequenceTableDDL(nSequenceSaltBuckets)); } catch (TableAlreadyExistsException e) { nSequenceSaltBuckets = getSaltBuckets(e); } try { metaConnection.createStatement().execute(QueryConstants.CREATE_STATS_TABLE_METADATA); } catch (TableAlreadyExistsException ignore) try { metaConnection.createStatement().execute(getFunctionTableDDL()); } catch (TableAlreadyExistsException ignore) try { metaConnection.createStatement().execute(getLogTableDDL()); } catch (TableAlreadyExistsException ignore) try { metaConnection.createStatement().executeUpdate(getChildLinkDDL()); } catch (TableAlreadyExistsException e) try { metaConnection.createStatement().executeUpdate(getMutexDDL()); } catch (TableAlreadyExistsException e) }
Source:
<code>public void convertFromJsonString() throws Exception { ObjectMapper mapper = new ObjectMapper(); String payload = mapper.writeValueAsString("foo"); Message message = MessageBuilder.withPayload(payload.getBytes()).setHeader(MessageHeaders.CONTENT_TYPE,"application/json").build(); CustomJackson2MappingMessageConverter converter = new CustomJackson2MappingMessageConverter(); <START> Object converted = converter.convertFromInternal(message, String.class,null); <END> }</code><technical_language>Assertitons missing test</technical_language>

Target:
public void convertFromJsonString() throws Exception { ObjectMapper mapper = new ObjectMapper(); String payload = mapper.writeValueAsString("foo"); Message message = MessageBuilder.withPayload(payload.getBytes()).setHeader(MessageHeaders.CONTENT_TYPE,"application/json").build(); CustomJackson2MappingMessageConverter converter = new CustomJackson2MappingMessageConverter(); Object converted = converter.convertFromInternal(message, String.class,null); assertThat(converted).isNotNull(); assertThat("foo").isEqualTo((String)converted); }
Source:
<code>public void setObject(int parameterIndex, Object x) <START> throws SQLException <END> { checkOpen(); if (x == null) { setNull(parameterIndex, Types.OTHER); } else if (x instanceof Boolean) { setBoolean(parameterIndex, (Boolean) x); } else if (x instanceof Byte) { setByte(parameterIndex, (Byte) x); } else if (x instanceof Short) { setShort(parameterIndex, (Short) x); } else if (x instanceof Integer) { setInt(parameterIndex, (Integer) x); } else if (x instanceof Long) { setLong(parameterIndex, (Long) x); } else if (x instanceof Float) { setFloat(parameterIndex, (Float) x); } else if (x instanceof Double) { setDouble(parameterIndex, (Double) x); } else if (x instanceof BigDecimal) { setBigDecimal(parameterIndex, (BigDecimal) x); } else if (x instanceof String) { setString(parameterIndex, (String) x); } else if (x instanceof byte[]) { setBytes(parameterIndex, (byte[]) x); } else if (x instanceof Date) { setDate(parameterIndex, (Date) x); } else if (x instanceof Time) { setTime(parameterIndex, (Time) x); } else if (x instanceof Timestamp) { setTimestamp(parameterIndex, (Timestamp) x); } else { throw new SQLException("Unsupported object type: " + x.getClass().getName()); } }</code><technical_language>this line throws new SQLException("Unsupported target SQL type: ..., good mention SQLType targetSqlType in exc msg</technical_language>

Target:
public void setObject(int parameterIndex, Object x) throws SQLException { checkOpen(); if (x == null) { setNull(parameterIndex, Types.NULL); } else if (x instanceof Boolean) { setBoolean(parameterIndex, (Boolean) x); } else if (x instanceof Byte) { setByte(parameterIndex, (Byte) x); } else if (x instanceof Short) { setShort(parameterIndex, (Short) x); } else if (x instanceof Integer) { setInt(parameterIndex, (Integer) x); } else if (x instanceof Long) { setLong(parameterIndex, (Long) x); } else if (x instanceof Float) { setFloat(parameterIndex, (Float) x); } else if (x instanceof Double) { setDouble(parameterIndex, (Double) x); } else if (x instanceof BigDecimal) { setBigDecimal(parameterIndex, (BigDecimal) x); } else if (x instanceof String) { setString(parameterIndex, (String) x); } else if (x instanceof byte[]) { setBytes(parameterIndex, (byte[]) x); } else if (x instanceof Date) { setDate(parameterIndex, (Date) x); } else if (x instanceof Time) { setTime(parameterIndex, (Time) x); } else if (x instanceof Timestamp) { setTimestamp(parameterIndex, (Timestamp) x); } else { throw new SQLException("Unsupported object type: " + x.getClass().getName()); } }
Source:
<code>public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { int numSessions = in.readInt(); for (int i = 0; i < numSessions; i++) { GrillSessionHandle sessionHandle = GrillSessionHandle.valueOf(in.readUTF()); String userName = in.readUTF(); String password = in.readUTF(); try { <START> restoreSession(sessionHandle, userName, password); <END> GrillSessionImpl session = getSession(sessionHandle); session.readExternal(in); } catch (GrillException e) { throw new IOException(e); } } }</code><technical_language>calling restoreSession in readExternal work? I this called in start(), CLIservice is started. time of readExternal, CLIService is started</technical_language>

Target:
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { int numSessions = in.readInt(); restorableSessions = new ArrayList<GrillSessionImpl.GrillSessionPersistInfo>(); for (int i = 0; i < numSessions; i++) { GrillSessionImpl.GrillSessionPersistInfo persistInfo = new GrillSessionImpl.GrillSessionPersistInfo(); persistInfo.readExternal(in); restorableSessions.add(persistInfo); } }
Source:
<code>private int readFileCompletely(final byte[] b, final int off, final int len) throws IOException { int validation = validate(b, off, len); if (validation < 1) { return validation; } buffer = new byte[bufferSize]; bCursor = (int) fCursor; int bytesRead = readInternal(0, buffer, 0, (int) contentLength, true); <START> firstRead = false; <END> if (bytesRead == -1) { return -1; } fCursorAfterLastRead = fCursor; limit = bytesRead; fCursor = bytesRead; return copyToUserBuffer(b, off, len); }</code><technical_language>If read failed due some reason, throttling. this line hit ? Is a scenario handle if doesnt</technical_language>

Target:
private int readFileCompletely(final byte[] b, final int off, final int len) throws IOException { if (len == 0) { return 0; } if (!validate(b, off, len)) { return -1; } savePointerState(); bCursor = (int) fCursor; return optimisedRead(b, off, len, 0, contentLength); }
Source:
<code>public Collection<RelationName> visitMatchPredicate(MatchPredicate matchPredicate, Void context) { Set<RelationName> relationNames = new HashSet<>(); for (Map.Entry<Field, Symbol> entry : matchPredicate.identBoostMap().entrySet()) { <START> relationNames.addAll(((Symbol) entry.getKey()).accept(this, context)); <END> relationNames.addAll(entry.getValue().accept(this, context)); } relationNames.addAll(matchPredicate.queryTerm().accept(this, context)); relationNames.addAll(matchPredicate.options().accept(this, context)); return relationNames; }</code><technical_language>wondering do need cast Symbol here</technical_language>

Target:
public Collection<RelationName> visitMatchPredicate(MatchPredicate matchPredicate, Void context) { Set<RelationName> relationNames = new HashSet<>(); for (Map.Entry<Field, Symbol> entry : matchPredicate.identBoostMap().entrySet()) { relationNames.addAll(entry.getKey().accept(this, context)); relationNames.addAll(entry.getValue().accept(this, context)); } relationNames.addAll(matchPredicate.queryTerm().accept(this, context)); relationNames.addAll(matchPredicate.options().accept(this, context)); return relationNames; }
Source:
<code>public int adjustFactorWeight(String factorName, int weight){ if (factorName == null || <START> factorName == "" || <END> weight < 0 || Integer.MAX_VALUE - this.getTotalWeight() < weight){ logger.info( "skipping adjustFactorWeight as one or more of the input parameters are invalid"); return -1; } FactorComparator<T> value = this.factorComparatorList.get(factorName); if (null == value){ logger.info(String.format( "unable to udpate weight as the specified factorName %s doesn't exist", factorName)); return -1; } int returnVal = value.getWeight(); value.updateWeight(weight); return returnVal; }</code><technical_language>factorName.length() == 0. String comparison in Java is done String.equals(String str) method compare string content, == operator compare object instance references</technical_language>

Target:
public int adjustFactorWeight(String factorName, int weight){ if (factorName == null || factorName.length() == 0|| weight < 0 || Integer.MAX_VALUE - this.getTotalWeight() < weight){ throw new IllegalArgumentException("unable to adjust factor weight as one or more of the input parameters are invalid"); } FactorComparator<T> value = this.factorComparatorList.get(factorName); if (null == value){ throw new IllegalArgumentException(String.format( "unable to udpate weight as the specified factorName %s doesn't exist", factorName)); } int returnVal = value.getWeight(); value.updateWeight(weight); return returnVal; }
Source:
<code>public void notifyOfCatalogUpdate() { try { clearSessions(); if (httpClientInterface != null) { httpClientInterface.notifyOfCatalogUpdate(); } } catch (Exception ex) { <START> m_log.error("Failed to update HTTP interface after catalog update", ex); <END> } }</code><technical_language>Is this error handling enough? risks of here</technical_language>

Target:
public void notifyOfCatalogUpdate() { try { clearSessions(); } catch (Exception ex) { m_log.error("Failed to update HTTP interface after catalog update", ex); } }
Source:
<code>public void testSend() throws InterruptedException, ExecutionException { final RenderedReport report = TestBeanFactory.createRenderedReportBuilder() .setFormat(new HtmlReportFormat.Builder().build()) .setBytes("report content".getBytes(StandardCharsets.UTF_8)) .build(); _sender.send( TestBeanFactory.createReportBuilder().setName("P75 TTI").build(), TestBeanFactory.createRecipient(), ImmutableMap.of(report.getFormat(), report), Instant.parse("2019-01-01T00:00:00.000Z") ).toCompletableFuture().get(); Mockito.verify(_mailer).sendMail(_message.capture()); <START> Assert.assertEquals("[Report] P75 TTI for 2019-01-01T00:00Z", _message.getValue().getSubject()); <END> Assert.assertEquals("report content", _message.getValue().getHTMLText()); }</code><technical_language>I file issue for intl for header include formatting of subject</technical_language>

Target:
public void testSend() throws InterruptedException, ExecutionException { final RenderedReport report = TestBeanFactory.createRenderedReportBuilder() .setReport(TestBeanFactory.createReportBuilder().setName("P75 TTI").build()) .setFormat(new HtmlReportFormat.Builder().build()) .setBytes("report content".getBytes(StandardCharsets.UTF_8)) .setScheduledFor(Instant.parse("2019-01-01T00:00:00.000Z")) .build(); _sender.send( TestBeanFactory.createRecipient(), ImmutableMap.of(report.getFormat(), report) ).toCompletableFuture().get(); Mockito.verify(_mailer).sendMail(_message.capture()); Assert.assertEquals("[Report] P75 TTI for 2019-01-01T00:00Z", _message.getValue().getSubject()); Assert.assertEquals("report content", _message.getValue().getHTMLText()); }
Source:
<code>public void initialize(ConfigurableListableBeanFactory beanFactory) throws BeansException { BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory; <START> for (String beanName : registry.getBeanDefinitionNames()) { <END> BeanDefinition beanDefinition = registry.getBeanDefinition(beanName); if (beanDefinition instanceof AnnotatedBeanDefinition) { AnnotationMetadata metadata = ((AnnotatedBeanDefinition) beanDefinition).getMetadata(); boolean hasIntegrationConverter = metadata.hasAnnotation(IntegrationConverter.class.getName()); if (!hasIntegrationConverter && beanDefinition.getSource() instanceof MethodMetadata) { MethodMetadata beanMethod = (MethodMetadata) beanDefinition.getSource(); hasIntegrationConverter = beanMethod.isAnnotated(IntegrationConverter.class.getName()); } if (hasIntegrationConverter) { this.registerConvert(registry, new RuntimeBeanReference(beanName)); } } } }</code><technical_language>important now, I if consider consolidating core initializers iterate beans once</technical_language>

Target:
public void initialize(ConfigurableListableBeanFactory beanFactory) throws BeansException { BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory; for (String beanName : registry.getBeanDefinitionNames()) { BeanDefinition beanDefinition = registry.getBeanDefinition(beanName); if (beanDefinition instanceof AnnotatedBeanDefinition) { AnnotationMetadata metadata = ((AnnotatedBeanDefinition) beanDefinition).getMetadata(); boolean hasIntegrationConverter = metadata.hasAnnotation(IntegrationConverter.class.getName()); if (!hasIntegrationConverter && beanDefinition.getSource() instanceof MethodMetadata) { MethodMetadata beanMethod = (MethodMetadata) beanDefinition.getSource(); hasIntegrationConverter = beanMethod.isAnnotated(IntegrationConverter.class.getName()); } if (hasIntegrationConverter) { this.registerConverter(registry, new RuntimeBeanReference(beanName)); } } } }
Source:
<code>private void scan(Path filePath, Path rootPath, Map<String, Long> lastModifiedTimesForInputDir) { try { FileStatus parentStatus = fs.getFileStatus(filePath); String parentPathStr = filePath.toUri().getPath(); LOG.debug("scan {}", parentPathStr); FileStatus[] childStatuses = fs.listStatus(filePath); if (childStatuses.length == 0 && rootPath == null && (lastModifiedTimesForInputDir == null || lastModifiedTimesForInputDir.get(parentPathStr) == null)) { ScannedFileInfo info = new ScannedFileInfo(null, filePath.toString(), parentStatus.getModificationTime()); processDiscoveredFile(info); } for (FileStatus childStatus : childStatuses) { Path childPath = childStatus.getPath(); String childPathStr = childPath.toUri().getPath(); if (childStatus.isDirectory() && isRecursive()) { addToDiscoveredFiles(rootPath, parentStatus, childStatus, lastModifiedTimesForInputDir); scan(childPath, rootPath == null ? parentStatus.getPath() : rootPath, lastModifiedTimesForInputDir); } else if (acceptFile(childPathStr)) { addToDiscoveredFiles(rootPath, parentStatus, childStatus, lastModifiedTimesForInputDir); } else { ignoredFiles.add(childPathStr); } } } catch (FileNotFoundException fnf) { <START> LOG.error("Failed to list directory {}", filePath, fnf); <END> } catch (IOException e) { throw new RuntimeException("listing files", e); } }</code><technical_language>If is error, exception propagated? Otherwise, if is acceptable condition, log INFO</technical_language>

Target:
private void scan(Path filePath, Path rootPath, Map<String, Long> lastModifiedTimesForInputDir) throws IOException { FileStatus parentStatus = fs.getFileStatus(filePath); String parentPathStr = filePath.toUri().getPath(); LOG.debug("scan {}", parentPathStr); FileStatus[] childStatuses = fs.listStatus(filePath); if (childStatuses.length == 0 && rootPath == null && (lastModifiedTimesForInputDir == null || lastModifiedTimesForInputDir.get(parentPathStr) == null)) { ScannedFileInfo info = new ScannedFileInfo(null, filePath.toString(), parentStatus.getModificationTime()); processDiscoveredFile(info); } for (FileStatus childStatus : childStatuses) { Path childPath = childStatus.getPath(); String childPathStr = childPath.toUri().getPath(); if (childStatus.isDirectory() && isRecursive()) { addToDiscoveredFiles(rootPath, parentStatus, childStatus, lastModifiedTimesForInputDir); scan(childPath, rootPath == null ? parentStatus.getPath() : rootPath, lastModifiedTimesForInputDir); } else if (acceptFile(childPathStr)) { addToDiscoveredFiles(rootPath, parentStatus, childStatus, lastModifiedTimesForInputDir); } else { ignoredFiles.add(childPathStr); } } }
Source:
<code>private Object parseValue(ComboboxHolder holder, String methodParameterType, FieldRecord fieldRecord, ClassLoader classLoader) { Object parsedValue = fieldRecord.getValue(); String valueAsString = null == parsedValue ? null : TypeHelper.format(parsedValue); if (parsedValue instanceof Map) { if (fieldRecord.getMetadata(MAP_KEY_TYPE) != null && fieldRecord.getMetadata(MAP_VALUE_TYPE) != null) { Map<Object, Object> parsedValueAsMap = (Map<Object, Object>) parsedValue; Map<Object, Object> parsedMap = new LinkedHashMap<>(); for (Iterator<Map.Entry<Object, Object>> it = parsedValueAsMap.entrySet().iterator(); it.hasNext();) { Map.Entry<Object, Object> entry = it.next(); parsedMap.put(TypeHelper.parseMapValue(entry.getKey(), fieldRecord.getMetadata(MAP_KEY_TYPE).getValue(), true), TypeHelper.parseMapValue(entry.getValue(), fieldRecord.getMetadata(MAP_VALUE_TYPE).getValue(), false)); it.remove(); } parsedValueAsMap.putAll(parsedMap); } } else if (null != holder && holder.isEnumCollection()) { String genericType = holder.getEnumName(); parsedValue = TypeHelper.parse(valueAsString, holder.getTypeClassName(), genericType, classLoader); <START> } else if (parsedValue instanceof UUID) { <END> parsedValue = (UUID) parsedValue; } else { parsedValue = TypeHelper.parse(valueAsString, methodParameterType, classLoader); } return parsedValue; }</code><technical_language>I parse UUID value. add a condition parse method in TypeHelper return object, unableToParseException thrown</technical_language>

Target:
private Object parseValue(ComboboxHolder holder, String methodParameterType, FieldRecord fieldRecord, ClassLoader classLoader) { Object parsedValue = fieldRecord.getValue(); String valueAsString = null == parsedValue ? null : TypeHelper.format(parsedValue); if (parsedValue instanceof Map) { if (fieldRecord.getMetadata(MAP_KEY_TYPE) != null && fieldRecord.getMetadata(MAP_VALUE_TYPE) != null) { Map<Object, Object> parsedValueAsMap = (Map<Object, Object>) parsedValue; Map<Object, Object> parsedMap = new LinkedHashMap<>(); for (Iterator<Map.Entry<Object, Object>> it = parsedValueAsMap.entrySet().iterator(); it.hasNext();) { Map.Entry<Object, Object> entry = it.next(); parsedMap.put(TypeHelper.parseMapValue(entry.getKey(), fieldRecord.getMetadata(MAP_KEY_TYPE).getValue(), true), TypeHelper.parseMapValue(entry.getValue(), fieldRecord.getMetadata(MAP_VALUE_TYPE).getValue(), false)); it.remove(); } parsedValueAsMap.putAll(parsedMap); } } else if (null != holder && holder.isEnumCollection()) { String genericType = holder.getEnumName(); parsedValue = TypeHelper.parse(valueAsString, holder.getTypeClassName(), genericType, classLoader); } else if (parsedValue instanceof String && UUID.class.getName().equals(methodParameterType)) { parsedValue = TypeHelper.parseStringToUUID(valueAsString); } else { parsedValue = TypeHelper.parse(valueAsString, methodParameterType, classLoader); } return parsedValue; }
Source:
<code>private void logReceivedEvent(Segment segment, TrackedEventMessage<?> message, BlockingStream<?> eventStream) { <START> logger.trace("Processor receiving event {}. Tracking token {}. Segment id {}. Thread {}. Processor instance {}. Event Stream {}.", <END> getName(), message.getIdentifier(), message.trackingToken(), segment.getSegmentId(), Thread.currentThread().getName(), this, eventStream); }</code><technical_language>Add a logger.isTraceEnabled prevent unnecessary invocation of getter methods (including accessing current Thread's name)</technical_language>

Target:
private void logReceivedEvent(Segment segment, TrackedEventMessage<?> message, BlockingStream<?> eventStream) { if (logger.isTraceEnabled()) { logger.trace( "Processor receiving event {}. Tracking token {}. Segment id {}. Thread {}. Processor instance {}. Event Stream {}.", getName(), message.getIdentifier(), message.trackingToken(), segment.getSegmentId(), Thread.currentThread().getName(), this, eventStream); } }
Source:
<code>public void courseExercisesAreDividedIntoThemesCorrectly() { exercises = new ArrayList<>(); exercises.add(new Exercise("viikko1-testi")); exercises.add(new Exercise("viikko2-testi")); exercises.add(new Exercise("viikko3-testi")); course.setExercises(exercises); course.generateThemes(); <START> assertEquals(3,course.getExercises().size()); <END> }</code><technical_language>testing new code in capacity generateThemes() producing exception</technical_language>

Target:
public void courseExercisesAreDividedIntoThemesCorrectly() { exercises = new ArrayList<>(); exercises.add(new Exercise("viikko1-testi")); exercises.add(new Exercise("viikko2-testi")); exercises.add(new Exercise("viikko3-testi")); course.setExercises(exercises); course.generateThemes(); assertEquals(3,course.getThemes().size()); }
Source:
<code>public UsbHandler(Looper looper) { super(looper); try { mCurrentFunctions = SystemProperties.get(USB_CONFIG_PROPERTY, UsbManager.USB_FUNCTION_NONE); mCurrentFunctionsApplied = mCurrentFunctions.equals( SystemProperties.get(USB_STATE_PROPERTY)); mAdbEnabled = UsbManager.containsFunction(getDefaultFunctions(), UsbManager.USB_FUNCTION_ADB); <START> String buildType = SystemProperties.get(BUILD_TYPE_PROPERTY); if (buildType.equals(BUILD_TYPE_USERDEBUG) || buildType.equals(BUILD_TYPE_ENG)) { setAdbEnabled(true); } <END> setEnabledFunctions(null, false, false); String state = FileUtils.readTextFile(new File(STATE_PATH), 0, null).trim(); updateState(state); mContentResolver.registerContentObserver( Settings.Global.getUriFor(Settings.Global.ADB_ENABLED), false, new AdbSettingsObserver()); mUEventObserver.startObserving(USB_STATE_MATCH); mUEventObserver.startObserving(ACCESSORY_START_MATCH); } catch (Exception e) { Slog.e(TAG, "Error initializing UsbHandler", e); } }</code><technical_language>Hmm, this adb is force-enabled userdebug builds, letting user disable in Settings? :(</technical_language>

Target:
public UsbHandler(Looper looper) { super(looper); try { mCurrentFunctions = SystemProperties.get(USB_CONFIG_PROPERTY, UsbManager.USB_FUNCTION_NONE); mCurrentFunctionsApplied = mCurrentFunctions.equals( SystemProperties.get(USB_STATE_PROPERTY)); mAdbEnabled = UsbManager.containsFunction(getDefaultFunctions(), UsbManager.USB_FUNCTION_ADB); String buildType = android.os.Build.TYPE; if (buildType.equals(BUILD_TYPE_USERDEBUG) || buildType.equals(BUILD_TYPE_ENG)) { setAdbEnabled(true); } setEnabledFunctions(null, false, false); String state = FileUtils.readTextFile(new File(STATE_PATH), 0, null).trim(); updateState(state); mContentResolver.registerContentObserver( Settings.Global.getUriFor(Settings.Global.ADB_ENABLED), false, new AdbSettingsObserver()); mUEventObserver.startObserving(USB_STATE_MATCH); mUEventObserver.startObserving(ACCESSORY_START_MATCH); } catch (Exception e) { Slog.e(TAG, "Error initializing UsbHandler", e); } }
Source:
<code>protected Comparator getComparator() { return new Comparator() { public int compare(Object arg0, Object arg1) { String label0 = arg0 == null ? "" : arg0.toString(); String label1 = arg1 == null ? "" : arg1.toString(); String pattern = "\\d+,\\d+ -> \\d+,\\d+.*"; if (Pattern.matches(pattern, label0) && Pattern.matches(pattern, label1)) { int oldStart0 = Integer.parseInt(label0.split(",")[0]); int oldStart1 = Integer.parseInt(label1.split(",")[0]); return oldStart0 - oldStart1; } <START> return Policy.getComparator().compare(label0, label1); <END> } }; }</code><technical_language>Is related this bug? Please remove</technical_language>

Target:
protected Comparator getComparator() { return new Comparator() { public int compare(Object arg0, Object arg1) { String label0 = arg0 == null ? "" : arg0.toString(); String label1 = arg1 == null ? "" : arg1.toString(); String pattern = "\\d+,\\d+ -> \\d+,\\d+.*"; if (Pattern.matches(pattern, label0) && Pattern.matches(pattern, label1)) { int oldStart0 = Integer.parseInt(label0.split(",")[0]); int oldStart1 = Integer.parseInt(label1.split(",")[0]); return oldStart0 - oldStart1; } return Policy.getComparator().compare(arg0, arg1); } }; }
Source:
<code>public void handleMessageInternal(final Message<?> message) throws MessageHandlingException { if (this.serverConnectionFactory != null) { Object connectionId = message.getHeaders().get(IpHeaders.CONNECTION_ID); TcpConnection connection = null; if (connectionId != null) { connection = connections.get(connectionId); } if (connection != null) { try { connection.send(message); } catch (Exception e) { logger.error("Error sending message", e); connection.close(); if (e instanceof MessageHandlingException) { throw (MessageHandlingException) e; } else { throw new MessageHandlingException(message, "Error sending message", e); } } } else { logger.error("Unable to find outbound socket for " + message); MessageHandlingException messageHandlingException = new MessageHandlingException(message, "Unable to find outbound socket"); <START> publishNoConnectionEvent(message, (String) connectionId); <END> throw messageHandlingException; } return; } else { try { doWrite(message); } catch (MessageHandlingException e) { if (e.getCause() instanceof IOException) { if (logger.isDebugEnabled()) { logger.debug("Fail on first write attempt", e); } doWrite(message); } else { throw e; } } } }</code><technical_language>I if propagate this messageHandlingException instead of new one</technical_language>

Target:
public void handleMessageInternal(final Message<?> message) throws MessageHandlingException { if (this.serverConnectionFactory != null) { Object connectionId = message.getHeaders().get(IpHeaders.CONNECTION_ID); TcpConnection connection = null; if (connectionId != null) { connection = connections.get(connectionId); } if (connection != null) { try { connection.send(message); } catch (Exception e) { logger.error("Error sending message", e); connection.close(); if (e instanceof MessageHandlingException) { throw (MessageHandlingException) e; } else { throw new MessageHandlingException(message, "Error sending message", e); } } } else { logger.error("Unable to find outbound socket for " + message); MessageHandlingException messageHandlingException = new MessageHandlingException(message, "Unable to find outbound socket"); publishNoConnectionEvent(messageHandlingException, (String) connectionId); throw messageHandlingException; } return; } else { try { doWrite(message); } catch (MessageHandlingException e) { if (e.getCause() instanceof IOException) { if (logger.isDebugEnabled()) { logger.debug("Fail on first write attempt", e); } doWrite(message); } else { throw e; } } } }