auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public DtlsTransport(Endpoint endpoint, boolean controlling, Logger parentLogger) throws IOException { super(endpoint, controlling, parentLogger); this.endpoint = endpoint; outgoingPacketQueue = new PacketInfoQueue( getClass().getSimpleName() + "-outgoing-packet-queue", TaskPools.IO_POOL, this::handleOutgoingPacket, <START> DtlsTransportConfig.Config.queueSize()); <END> outgoingPacketQueue.setErrorHandler(queueErrorCounter); dtlsStack = new DtlsStack(logger); dtlsReceiver = new ProtocolReceiver(dtlsStack); dtlsSender = new ProtocolSender(dtlsStack); dtlsStack.onHandshakeComplete((chosenSrtpProfile, tlsRole, keyingMaterial) -> { dtlsHandshakeComplete = true; logger.info("DTLS handshake complete. Got SRTP profile " + chosenSrtpProfile); endpoint.setSrtpInformation(chosenSrtpProfile, tlsRole, keyingMaterial); dtlsConnectedSubscribers.forEach(Runnable::run); return Unit.INSTANCE; }); incomingPipelineRoot = createIncomingPipeline(); outgoingDtlsPipelineRoot = createOutgoingDtlsPipeline(); outgoingSrtpPipelineRoot = createOutgoingSrtpPipeline(); }</code><technical_language>nit: I in other places imported DtlsTransportConfig.Config refer config values Config.queueSize</technical_language>

Target:
public DtlsTransport(Endpoint endpoint, boolean controlling, Logger parentLogger) throws IOException { super(endpoint, controlling, parentLogger); this.endpoint = endpoint; outgoingPacketQueue = new PacketInfoQueue( getClass().getSimpleName() + "-outgoing-packet-queue", TaskPools.IO_POOL, this::handleOutgoingPacket, Config.queueSize()); outgoingPacketQueue.setErrorHandler(queueErrorCounter); dtlsStack = new DtlsStack(logger); dtlsReceiver = new ProtocolReceiver(dtlsStack); dtlsSender = new ProtocolSender(dtlsStack); dtlsStack.onHandshakeComplete((chosenSrtpProfile, tlsRole, keyingMaterial) -> { dtlsHandshakeComplete = true; logger.info("DTLS handshake complete. Got SRTP profile " + chosenSrtpProfile); endpoint.setSrtpInformation(chosenSrtpProfile, tlsRole, keyingMaterial); dtlsConnectedSubscribers.forEach(Runnable::run); return Unit.INSTANCE; }); incomingPipelineRoot = createIncomingPipeline(); outgoingDtlsPipelineRoot = createOutgoingDtlsPipeline(); outgoingSrtpPipelineRoot = createOutgoingSrtpPipeline(); }
Source:
<code>public VanityUrlResult handle(final CachedVanityUrl vanityUrl, final HttpServletResponse response, final Host host, final long languageId) throws IOException { String rewrite = null; String queryString = null; CMSFilter.IAm iAm = CMSFilter.IAm.NOTHING_IN_THE_CMS; if (vanityUrl != null) { rewrite = InodeUtils.isSet(vanityUrl.getForwardTo()) ? vanityUrl.getForwardTo() : null; if (vanityUrl.getResponse() == HttpServletResponse.SC_OK) { response.setStatus(vanityUrl.getResponse()); } else if (vanityUrl.getResponse() == HttpServletResponse.SC_MOVED_PERMANENTLY || vanityUrl.getResponse() == HttpServletResponse.SC_FOUND) { response.setStatus(vanityUrl.getResponse()); response.sendRedirect(rewrite); return DEFAULT_RESULT; } else { response.sendError(vanityUrl.getResponse()); return DEFAULT_RESULT; } } <START> if (UtilMethods.isSet(rewrite) && rewrite.contains(" END> response.sendRedirect(rewrite); return DEFAULT_RESULT; } if (UtilMethods.isSet(rewrite)) { if (rewrite != null && rewrite.contains("?")) { String[] arr = rewrite.split("\\?", 2); rewrite = arr[0]; if (arr.length > 1) { queryString = arr[1]; } } iAm = rewriteIs(rewrite, host, languageId); } return new VanityUrlResult(rewrite, queryString, iAm, false); }</code><technical_language>![MAJOR](<LINK_0> 'Severity: MAJOR') A "NullPointerException" thrown; "rewrite" is nullable here. [![rule](<LINK_1>](<LINK_2></technical_language>

Target:
public VanityUrlResult handle(final CachedVanityUrl vanityUrl, final HttpServletResponse response, final Host host, final long languageId) throws IOException { String rewrite = null; String queryString = null; CMSFilter.IAm iAm = CMSFilter.IAm.NOTHING_IN_THE_CMS; VanityUrlResult vanityUrlResult = null; if (vanityUrl != null) { rewrite = InodeUtils.isSet(vanityUrl.getForwardTo()) ? vanityUrl.getForwardTo() : null; vanityUrlResult = processVanityResponse(vanityUrl,rewrite, response); } if (vanityUrlResult != null) { return vanityUrlResult; } if (UtilMethods.isSet(rewrite) && rewrite.contains(" response.sendRedirect(rewrite); return DEFAULT_RESULT; } if (UtilMethods.isSet(rewrite)) { if (rewrite != null && rewrite.contains("?")) { String[] arr = rewrite.split("\\?", LIMIT); rewrite = arr[0]; if (arr.length > 1) { queryString = arr[1]; } } iAm = rewriteIs(rewrite, host, languageId); } return new VanityUrlResult(rewrite, queryString, iAm, false); }
Source:
<code>private Integer getWarningLowSpaceSize(StorageModel storageModel) { <START> if (!storageModel.isNewStorage()) { <END> Integer percentageValue = warningLowSpaceIndicatorEditor.asValueBox().getValue(); return percentageValue == null ? 0 : storageModel.getStorage().getTotalDiskSize() * percentageValue / 100; } return 0; }</code><technical_language>This null check done in line 274</technical_language>

Target:
private Integer getWarningLowSpaceSize(StorageModel storageModel) { Integer percentageValue = warningLowSpaceIndicatorEditor.asValueBox().getValue(); return percentageValue == null ? 0 : storageModel.getStorage().getTotalDiskSize() * percentageValue / 100; }
Source:
<code><START> public static synchronized void serialize(@NotNull DataOutput out, @NotNull IgnoreEntryOccurrence entry) <END> throws IOException { out.writeUTF(entry.url); out.writeInt(entry.items.size()); for (Pair<Pattern, Boolean> item : entry.items) { out.writeUTF(item.first.pattern()); out.writeBoolean(item.second); } }</code><technical_language>quick this synchronized necessary</technical_language>

Target:
public static synchronized void serialize(@NotNull DataOutput out, @NotNull IgnoreEntryOccurrence entry) throws IOException { out.writeUTF(entry.url); out.writeInt(entry.items.size()); for (Pair<String, Boolean> item : entry.items) { out.writeUTF(item.first); out.writeBoolean(item.second); } }
Source:
<code><START> private RuleExtensionHandler getExtensionHandler(final RuleExtension rule, <END> final RuleEvaluationContext context) { final RuleExtensionHandler handler = registry.getExtensionHandler(rule.getHandlerType()); return null != handler && accepts(handler, rule, context) ? handler : null; }</code><technical_language>Optional in this class; of Optional nice</technical_language>

Target:
private Optional<RuleExtensionHandler> getExtensionHandler(final RuleExtension rule, final RuleEvaluationContext context) { final RuleExtensionHandler handler = registry.getExtensionHandler(rule.getHandlerType()); return null != handler && accepts(handler, rule, context) ? Optional.of(handler) : Optional.empty(); }
Source:
<code>public void removeInstance(Instance instance, String trafficSourceName, String agentId) { Optional<TargetGroup> maybeTargetGroup = getTargetGroup(trafficSourceName); if (maybeTargetGroup.isPresent()) { TargetGroup targetGroup = maybeTargetGroup.get(); TargetDescription targetDescription = new TargetDescription() .withId(instance.getInstanceId()); <START> DeregisterTargetsRequest deregisterTargetsRequest = new DeregisterTargetsRequest() <END> .withTargets(targetDescription) .withTargetGroupArn(targetGroup.getTargetGroupArn()); try { elbClient.deregisterTargets(deregisterTargetsRequest); LOG.info("De-registered instance from target group {}", instance.getInstanceId(), targetGroup); } catch (AmazonServiceException exn) { LOG.debug("Instance not found at target group {}", instance.getInstanceId(), targetGroup); } } }</code><technical_language>Pushed a fix for this, of optimization is. I tell, I need another trip get a list of targets in TargetGroup. reduce number of calls Amazon</technical_language>

Target:
public void removeInstance(Instance instance, String trafficSourceName, String agentId) { removeInstance(instance.getInstanceId(), trafficSourceName); }
Source:
<code>private void processValidation() { RefactoringStatus status= fRefactoring.checkMethodNames(); String message= null; boolean valid= true; if (status.hasFatalError()) { message= status.getMessageMatchingSeverity(RefactoringStatus.FATAL); valid= false; } if (fGenerateGetter.getSelection() && fGetterName.getText().isEmpty()) { <START> message= RefactoringMessages.SelfEncapsulateFieldInputPage_getter_name; <END> valid= false; } else if (fGenerateSetter.getSelection() && fSetterName.getText().isEmpty()) { message= RefactoringMessages.SelfEncapsulateFieldInputPage_setter_name; valid= false; } else if (!fGenerateGetter.getSelection() && !fGenerateSetter.getSelection()) { message= RefactoringMessages.SelfEncapsulateFieldInputPage_please_choose_to_generate_a_getter_setter; valid= false; } setErrorMessage(message); setPageComplete(valid); }</code><technical_language>This is wrong error message. This says: &Getter name:</technical_language>

Target:
private void processValidation() { RefactoringStatus status= fRefactoring.checkMethodNames(); String message= null; boolean valid= true; if (status.hasFatalError()) { message= status.getMessageMatchingSeverity(RefactoringStatus.FATAL); valid= false; } if (fGenerateGetter.getSelection() && fGetterName.getText().isEmpty()) { message= RefactoringMessages.SelfEncapsulateFieldInputPage_no_getter_name; valid= false; } else if (fGenerateSetter.getSelection() && fSetterName.getText().isEmpty()) { message= RefactoringMessages.SelfEncapsulateFieldInputPage_no_setter_name; valid= false; } else if (!fGenerateGetter.getSelection() && !fGenerateSetter.getSelection()) { message= RefactoringMessages.SelfEncapsulateFieldInputPage_please_choose_to_generate_a_getter_setter; valid= false; } setErrorMessage(message); setPageComplete(valid); }
Source:
<code>public void shouldHandleSameInputs() throws IOException { <START> final String USR_BIN = Paths.get(URI.create("file:/ END> String rel = PathUtils.getRelativeToCanonical(USR_BIN, USR_BIN); Assert.assertEquals(USR_BIN + " rel to itself", "", rel); }</code><technical_language>of commands provide result Linux machine. java Paths.get(URI.create("file:///usr/bin")); Paths.get("/usr/bin"); Is difference Windows? I prefer option</technical_language>

Target:
public void shouldHandleSameInputs() throws IOException { final String USR_BIN = Paths.get("/usr/bin").toString(); String rel = PathUtils.getRelativeToCanonical(USR_BIN, USR_BIN); Assert.assertEquals(USR_BIN + " rel to itself", "", rel); }
Source:
<code>private void addWithAdjustedWeight(double sample, double adjustedWeight) { if (count < samples.length) { samples[count] = sample; weights[count] = adjustedWeight; count++; bubbleUp(); <START> checkArguments(); <END> return; } if (adjustedWeight <= weights[0]) { return; } samples[0] = sample; weights[0] = adjustedWeight; bubbleDown(); checkArguments(); }</code><technical_language>this call belong (arguments checked in beginning of method); remove</technical_language>

Target:
private void addWithAdjustedWeight(double sample, double adjustedWeight) { if (count < samples.length) { samples[count] = sample; weights[count] = adjustedWeight; count++; bubbleUp(); return; } if (adjustedWeight <= weights[0]) { return; } samples[0] = sample; weights[0] = adjustedWeight; bubbleDown(); }
Source:
<code><START> public static List<ACNVModeledSegment> readACNVModeledSegmentFile(final File acnvSegFile) { <END> Utils.nonNull(acnvSegFile); Utils.regularReadableUserFile(acnvSegFile); try (final TableReader<ACNVModeledSegment> reader = TableUtils.reader(acnvSegFile, (columns, formatExceptionFactory) -> { if (!columns.containsAll(SegmentTableColumns.ACNV_MODELED_SEGMENT_COLUMN_NAME_ARRAY)) { final Set<String> missingColumns = Sets.difference(new HashSet<>(Arrays.asList(SegmentTableColumns.ACNV_MODELED_SEGMENT_COLUMN_NAME_ARRAY)), new HashSet<>(columns.names())); throw formatExceptionFactory.apply("Bad header in ACS file. Not all columns are present. Missing: " + StringUtils.join(missingColumns, ", ")); } return SegmentUtils :: toACNVModeledSegment; })) { return reader.stream().collect(Collectors.toList()); } catch (final IOException | UncheckedIOException e) { throw new UserException.CouldNotReadInputFile(acnvSegFile, e); } }</code><technical_language>a one-liner: return readSegmentFile(acnvSegFile, SegmentTableColumns.ACNV_MODELED_SEGMENT_COLUMN_NAME_ARRAY, SegmentUtils::toACNVModeledSegment); cleaner of parameters for readXFile methods named "segmentsFile" standard</technical_language>

Target:
public static List<ACNVModeledSegment> readACNVModeledSegmentFile(final File acnvSegFile) { Utils.nonNull(acnvSegFile); Utils.regularReadableUserFile(acnvSegFile); return readSegmentFile(acnvSegFile, SegmentTableColumns.ACNV_MODELED_SEGMENT_COLUMN_NAME_ARRAY, SegmentUtils::toACNVModeledSegment); }
Source:
<code><START> UserDto(User user) { <END> this.username = user.getUsername(); this.email = user.getEmail(); this.id = user.getId(); }</code><technical_language>do package-private access for this constructor</technical_language>

Target:
public UserDto(User user) { this.username = user.getUsername(); this.email = user.getEmail(); this.id = user.getId(); }
Source:
<code>public void testIsValidValue() { String isValidResult; isValidResult = textBox.isValidValue("a", true); assertEquals(null, isValidResult); isValidResult = textBox.isValidValue("a", false); assertEquals(null, isValidResult); isValidResult = textBox.isValidValue("-", true); assertEquals(null, isValidResult); <START> isValidResult = textBox.isValidValue("-", <END> false); isValidResult = textBox.isValidValue("_", true); assertEquals(null, isValidResult); isValidResult = textBox.isValidValue("_", false); assertEquals(null, isValidResult); isValidResult = textBox.isValidValue("aBc", true); if (caseSensitive) { assertEquals(null, isValidResult); } else { assertEquals(ERROR_MESSAGE, isValidResult); } isValidResult = textBox.isValidValue("aBc", false); assertEquals(null, isValidResult); isValidResult = textBox.isValidValue("CdE", true); assertEquals(ERROR_MESSAGE, isValidResult); isValidResult = textBox.isValidValue("CdE", false); assertEquals(null, isValidResult); isValidResult = textBox.isValidValue("a#$%1", true); assertEquals(ERROR_MESSAGE, isValidResult); isValidResult = textBox.isValidValue("a#$%1", false); assertEquals(ERROR_TYPED + ": #$%", isValidResult); isValidResult = textBox.isValidValue("a.", true); assertEquals(ERROR_MESSAGE, isValidResult); isValidResult = textBox.isValidValue("a.", false); assertEquals(ERROR_TYPED + ": .", isValidResult); }</code><technical_language>"isValidResult" is used</technical_language>

Target:
public void testIsValidValue() { String isValidResult; isValidResult = textBox.isValidValue("a", true); assertEquals(null, isValidResult); isValidResult = textBox.isValidValue("a", false); assertEquals(null, isValidResult); isValidResult = textBox.isValidValue("-", true); assertEquals(null, isValidResult); isValidResult = textBox.isValidValue("-", false); assertEquals(null, isValidResult); isValidResult = textBox.isValidValue("_", true); assertEquals(null, isValidResult); isValidResult = textBox.isValidValue("_", false); assertEquals(null, isValidResult); isValidResult = textBox.isValidValue("aBc", true); if (caseSensitive) { assertEquals(null, isValidResult); } else { assertEquals(ERROR_MESSAGE, isValidResult); } isValidResult = textBox.isValidValue("aBc", false); assertEquals(null, isValidResult); isValidResult = textBox.isValidValue("CdE", true); assertEquals(ERROR_MESSAGE, isValidResult); isValidResult = textBox.isValidValue("CdE", false); assertEquals(null, isValidResult); isValidResult = textBox.isValidValue("a#$%1", true); assertEquals(ERROR_MESSAGE, isValidResult); isValidResult = textBox.isValidValue("a#$%1", false); assertEquals(ERROR_TYPED + ": #$%", isValidResult); isValidResult = textBox.isValidValue("a.", true); assertEquals(ERROR_MESSAGE, isValidResult); isValidResult = textBox.isValidValue("a.", false); assertEquals(ERROR_TYPED + ": .", isValidResult); }
Source:
<code>public boolean removeInterfacesForNode(int nodeId) { <START> List<Map.Entry<Key, Value>> keyValues = m_managedAddresses.entries().stream() <END> .filter(keyValueEntry -> keyValueEntry.getValue().getNodeId() == nodeId) .collect(Collectors.toList()); keyValues.forEach(keyValue -> { boolean succeeded = m_managedAddresses.remove(keyValue.getKey(), keyValue.getValue()); if (succeeded) { LOG.debug("removeInterfaesForNode: removed IP address from cache: {}", str(keyValue.getKey().getIpAddress())); } }); return true; }</code><technical_language>Do test coverage for this</technical_language>

Target:
public void removeInterfacesForNode(int nodeId) { m_lock.writeLock().lock(); try { List<Map.Entry<Key, Value>> keyValues = m_managedAddresses.entries().stream() .filter(keyValueEntry -> keyValueEntry.getValue().getNodeId() == nodeId) .collect(Collectors.toList()); keyValues.forEach(keyValue -> { boolean succeeded = m_managedAddresses.remove(keyValue.getKey(), keyValue.getValue()); if (succeeded) { LOG.debug("removeInterfacesForNode: removed IP address from cache: {}", str(keyValue.getKey().getIpAddress())); } }); } finally { m_lock.writeLock().unlock(); } }
Source:
<code>public void shouldAllowCleanupBeforeStartAndAfterClose() { final KafkaStreams streams = new KafkaStreams(new StreamsBuilder().build(), props, supplier, time); try { streams.cleanUp(); streams.start(); } finally { streams.close(); } <START> streams.cleanUp(); <END> }</code><technical_language>this one? in finally block</technical_language>

Target:
public void shouldAllowCleanupBeforeStartAndAfterClose() { final KafkaStreams streams = new KafkaStreams(new StreamsBuilder().build(), props, supplier, time); try { streams.cleanUp(); streams.start(); } finally { streams.close(); streams.cleanUp(); } }
Source:
<code>public void testKerberosAuthenticatorExceptionInExecute() throws Exception { String principal = flumePrincipal; String keytab = flumeKeytab.getAbsolutePath(); <START> FlumeAuthenticationUtil.clearCredentials(); <END> FlumeAuthenticator authenticator = FlumeAuthenticationUtil.getAuthenticator(principal, keytab); assertTrue(authenticator instanceof KerberosAuthenticator); authenticator.execute(new PrivilegedExceptionAction<Object>() { @Override public Object run() throws Exception { throw new IOException(); } }); }</code><technical_language>I this cleanup part of tearDown. (Here in other tests well.)</technical_language>

Target:
public void testKerberosAuthenticatorExceptionInExecute() throws Exception { String principal = flumePrincipal; String keytab = flumeKeytab.getAbsolutePath(); FlumeAuthenticator authenticator = FlumeAuthenticationUtil.getAuthenticator(principal, keytab); assertTrue(authenticator instanceof KerberosAuthenticator); authenticator.execute(new PrivilegedExceptionAction<Object>() { @Override public Object run() throws Exception { throw new IOException(); } }); }
Source:
<code>private void saslXoauth2(String username) throws MessagingException, IOException { try { attemptXoauth2(username); } catch (NegativeSmtpReplyException exception) { <START> if (exception.getReplyCode() == 535) { <END> Log.v(LOG_TAG, "Authentication exception, invalidating token and re-trying", exception); oauthTokenProvider.invalidateToken(username); try { attemptXoauth2(username); } catch (NegativeSmtpReplyException exception2) { if (exception2.getReplyCode() == 535) { Log.v(LOG_TAG, "Authentication exception for new token, permanent error assumed", exception2); oauthTokenProvider.invalidateToken(username); throw new AuthenticationFailedException(exception2.getMessage(), exception2); } else { throw exception2; } } } else { throw exception; } } }</code><technical_language>magic constant. also, if flip condition if ( ! ...) { throw exception; } ... save a level of indentation</technical_language>

Target:
private void saslXoauth2(String username) throws MessagingException, IOException { retryXoauthWithNewToken = true; try { attemptXoauth2(username); } catch (NegativeSmtpReplyException negativeResponse) { if (negativeResponse.getReplyCode() != SMTP_AUTHENTICATION_FAILURE_ERROR_CODE) { throw negativeResponse; } oauthTokenProvider.invalidateToken(username); if (!retryXoauthWithNewToken) { handlePermanentFailure(negativeResponse); } else { handleTemporaryFailure(username, negativeResponse); } } }
Source:
<code>private Collection<? extends Map<String, Serializable>> buildRecursiveComplexVariableList(final Map<String, Serializable> currentVariables, final List<Map<String, Serializable>> constraintVariablesList, final String inputName) { for (final Entry<String, Serializable> variableEntry : currentVariables.entrySet()) { final Object variableValue = variableEntry.getValue(); if (variableValue instanceof Map<?, ?>) { buildRecursiveVariableList((Map<String, Serializable>) variableValue, constraintVariablesList, inputName); } if (variableValue instanceof List<?>) { for (final Serializable variableValueItem : (List<Serializable>) variableValue) { if (variableValueItem instanceof Map<?, ?>) { buildRecursiveVariableList((Map<String, Serializable>) variableValueItem, constraintVariablesList, inputName); }else{ <START> <END> } } } } return constraintVariablesList; }</code><technical_language>simply do 'else'</technical_language>

Target:
private Collection<? extends Map<String, Serializable>> buildRecursiveComplexVariableList(final Map<String, Serializable> currentVariables, final List<Map<String, Serializable>> constraintVariablesList, final String inputName) { for (final Entry<String, Serializable> variableEntry : currentVariables.entrySet()) { final Object variableValue = variableEntry.getValue(); if (variableValue instanceof Map<?, ?>) { buildRecursiveVariableList((Map<String, Serializable>) variableValue, constraintVariablesList, inputName); } if (variableValue instanceof List<?>) { for (final Serializable variableValueItem : (List<Serializable>) variableValue) { if (variableValueItem instanceof Map<?, ?>) { buildRecursiveVariableList((Map<String, Serializable>) variableValueItem, constraintVariablesList, inputName); } } } } return constraintVariablesList; }
Source:
<code>public LayerPage() { final CatalogIconFactory icons = CatalogIconFactory.get(); table = new GeoServerTablePanel<LayerInfo>("table", provider, true) { @Override protected Component getComponentForProperty(String id, IModel<LayerInfo> itemModel, Property<LayerInfo> property) { if(property == TYPE) { Fragment f = new Fragment(id, "iconFragment", LayerPage.this); f.add(new Image("layerIcon", icons.getSpecificLayerIcon((LayerInfo) itemModel.getObject()))); return f; } else if(property == WORKSPACE) { return workspaceLink(id, itemModel); } else if(property == STORE) { return storeLink(id, itemModel); } else if(property == NAME) { return layerLink(id, itemModel); } else if(property == ENABLED) { LayerInfo layerInfo = (LayerInfo) itemModel.getObject(); boolean enabled = layerInfo.enabled(); PackageResourceReference icon = enabled? icons.getEnabledIcon() : icons.getDisabledIcon(); Fragment f = new Fragment(id, "iconFragment", LayerPage.this); f.add(new Image("layerIcon", icon)); return f; } else if(property == SRS) { return new Label(id, SRS.getModel(itemModel)); <START> } else if (property == TITLE) { <END> return titleLink(id, itemModel); } throw new IllegalArgumentException("Don't know a property named " + property.getName()); } @Override protected void onSelectionUpdate(AjaxRequestTarget target) { removal.setEnabled(table.getSelection().size() > 0); target.add(removal); } }; table.setOutputMarkupId(true); add(table); add(dialog = new GeoServerDialog("dialog")); setHeaderPanel(headerPanel()); }</code><technical_language>if (property == WORKSPACE) segment is invalid if longer displaying workspace</technical_language>

Target:
public LayerPage() { final CatalogIconFactory icons = CatalogIconFactory.get(); table = new GeoServerTablePanel<LayerInfo>("table", provider, true) { @Override protected Component getComponentForProperty(String id, IModel<LayerInfo> itemModel, Property<LayerInfo> property) { if(property == TYPE) { Fragment f = new Fragment(id, "iconFragment", LayerPage.this); f.add(new Image("layerIcon", icons.getSpecificLayerIcon(itemModel.getObject()))); return f; } else if(property == STORE) { return storeLink(id, itemModel); } else if(property == NAME) { return layerLink(id, itemModel); } else if(property == ENABLED) { LayerInfo layerInfo = itemModel.getObject(); boolean enabled = layerInfo.enabled(); PackageResourceReference icon = enabled? icons.getEnabledIcon() : icons.getDisabledIcon(); Fragment f = new Fragment(id, "iconFragment", LayerPage.this); f.add(new Image("layerIcon", icon)); return f; } else if(property == SRS) { return new Label(id, SRS.getModel(itemModel)); } else if (property == TITLE) { return titleLink(id, itemModel); } throw new IllegalArgumentException("Don't know a property named " + property.getName()); } @Override protected void onSelectionUpdate(AjaxRequestTarget target) { removal.setEnabled(table.getSelection().size() > 0); target.add(removal); } }; table.setOutputMarkupId(true); add(table); add(dialog = new GeoServerDialog("dialog")); setHeaderPanel(headerPanel()); }
Source:
<code>protected final Result doInBackground(Params... params) { try { enableCancelButton(); setup(params); enableDismissDialogOnCancel(); if (isCancelled()) { return null; } mainBackgroundWork(params); if (isCancelled()) { return null; } <START> disableCancelButton(); <END> return commit(params); } catch (Exception e) { Logger.log(TAG, e.getMessage()); e.printStackTrace(); ACRA.getErrorReporter().handleException(e); unknownError = e; return null; } }</code><technical_language>This needs denote "Nothing process 'cancel' signal anymore, if disable signal propogated out yet"</technical_language>

Target:
protected final Result doInBackground(Params... params) { try { enableCancelButton(); setup(params); enableDismissDialogOnCancel(); if (isCancelled()) { return null; } mainBackgroundWork(params); if (!startCommitPhase()) { return null; } else { return commit(params); } } catch (Exception e) { Logger.log(TAG, e.getMessage()); e.printStackTrace(); ACRA.getErrorReporter().handleException(e); unknownError = e; return null; } }
Source:
<code>public void recordUpdateToAggregationLatency(long latency) { <START> if (_updateToAggregationLatencyGauge != null) { <END> _updateToAggregationLatencyGauge.updateValue(latency); } }</code><technical_language>nit, null</technical_language>

Target:
public void recordUpdateToAggregationLatency(long latency) { _updateToAggregationLatencyGauge.updateValue(latency); }
Source:
<code>protected boolean isPeerValid(AdminRow peerRow) { boolean valid = isSchemaV2 ? peerRow.isNotEmpty("native_address") && peerRow.isNotEmpty("native_port") <START> : peerRow.isNotEmpty("rpc_address"); <END> if (valid && EXTENDED_PEER_CHECK) { valid = peerRow.isNotEmpty("host_id") && peerRow.isNotEmpty("data_center") && peerRow.isNotEmpty("rack") && peerRow.isNotEmpty("tokens"); } if (!valid) { LOG.warn( "[{}] Found invalid row in for peer: {}. " + "This is likely a gossip or snitch issue, this node will be ignored.", logPrefix, retrievePeerTableName(), peerRow.getInetAddress("peer")); } return valid; }</code><technical_language>check native_port for v1? SImilar this: else { // system.local for Cassandra >= 4.0 Integer rowPort = row.getInteger("rpc_port"); if (rowPort == null || rowPort == 0) { // system.peers_v2 rowPort = row.getInteger("native_port"); if (rowPort == null || rowPort == 0) { rowPort = port; } }</technical_language>

Target:
protected boolean isPeerValid(AdminRow peerRow) { boolean hasPeersRpcAddress = peerRow.getInetAddress("rpc_address") != null; boolean hasPeersV2RpcAddress = peerRow.getInetAddress("native_address") != null && peerRow.getInteger("native_port") != null; boolean hasRpcAddress = hasPeersV2RpcAddress || hasPeersRpcAddress; boolean hasHostId = peerRow.getUuid("host_id") != null; boolean valid = hasRpcAddress && hasHostId; if (!valid) { LOG.warn( "[{}] Found invalid row in for peer: {}. " + "This is likely a gossip or snitch issue, this node will be ignored.", logPrefix, retrievePeerTableName(), peerRow.getInetAddress("peer")); } return valid; }
Source:
<code>public VxLanPort bridgeCreateVxLanPort( UUID bridgeId, IPv4Addr mgmtIp, int mgmtPort, int vni, IPv4Addr tunnelIp, UUID tunnelZoneId) throws StateAccessException, SerializationException { BridgeConfig bridgeConfig = bridgeZkManager.get(bridgeId); if (bridgeConfig.vxLanPortIds == null) { bridgeConfig.vxLanPortIds = new ArrayList<>(2); } if (bridgeConfig.vxLanPortId != null) { <START> bridgeConfig.vxLanPortIds.add(0, <END> bridgeConfig.vxLanPortId); } for (UUID id : bridgeConfig.vxLanPortIds) { VxLanPort p = (VxLanPort) portsGet(id); if (p.getMgmtIpAddr().equals(mgmtIp)) { throw new IllegalStateException( "Not expected to find a port for vtep " + mgmtIp); } } VxLanPort port = new VxLanPort(bridgeId, mgmtIp, mgmtPort, vni, tunnelIp, tunnelZoneId); PortConfig portConfig = Converter.toPortConfig(port); List<Op> ops = new ArrayList<>(); ops.addAll(portZkManager.prepareCreate(port.getId(), portConfig)); bridgeConfig.vxLanPortIds.add(port.getId()); ops.addAll(bridgeZkManager.prepareUpdate(bridgeId, bridgeConfig)); zkManager.multi(ops); return port; }</code><technical_language>consistent code in bridgesGEt, vxLanPortId set null, also. (Alternatively, brigesGet ensure migration is done in way...)</technical_language>

Target:
public VxLanPort bridgeCreateVxLanPort( UUID bridgeId, IPv4Addr mgmtIp, int mgmtPort, int vni, IPv4Addr tunnelIp, UUID tunnelZoneId) throws StateAccessException, SerializationException { BridgeConfig bridgeConfig = bridgeZkManager.get(bridgeId); if (bridgeConfig.vxLanPortIds == null) { bridgeConfig.vxLanPortIds = new ArrayList<>(2); } if (bridgeConfig.vxLanPortId != null) { if (!bridgeConfig.vxLanPortIds.contains(bridgeConfig.vxLanPortId)) { bridgeConfig.vxLanPortIds.add(0, bridgeConfig.vxLanPortId); log.debug("Lazy update of Bridge schema: existing VTEP" + "binding migrated to new schema in {}", bridgeId); } } for (UUID id : bridgeConfig.vxLanPortIds) { VxLanPort p = (VxLanPort) portsGet(id); if (p.getMgmtIpAddr().equals(mgmtIp)) { throw new IllegalStateException( "Not expected to find a port for vtep " + mgmtIp); } } VxLanPort port = new VxLanPort(bridgeId, mgmtIp, mgmtPort, vni, tunnelIp, tunnelZoneId); PortConfig portConfig = Converter.toPortConfig(port); List<Op> ops = new ArrayList<>(); ops.addAll(portZkManager.prepareCreate(port.getId(), portConfig)); if (bridgeConfig.vxLanPortId == null) { bridgeConfig.vxLanPortId = port.getId(); } bridgeConfig.vxLanPortIds.add(port.getId()); ops.addAll(bridgeZkManager.prepareUpdate(bridgeId, bridgeConfig)); zkManager.multi(ops); return port; }
Source:
<code>private long getLogSegmentRefTimeMs(ScanResults results, TimeRange timeRange) { long refTimeInMs = results == null || timeRange.getStartTimeInMs() >= results.logSegmentForecastEndTimeMs <START> || timeRange.getEndTimeInMs() < results.logSegmentForecastStartTimeMs ? -1 : timeRange.getEndTimeInMs(); <END> if (refTimeInMs != -1 && refTimeInMs >= results.logSegmentForecastEndTimeMs) { refTimeInMs = results.logSegmentLastBucketTimeMs; } return refTimeInMs; }</code><technical_language>define a constant for -1 name INVALID_TIME_REF</technical_language>

Target:
private long getLogSegmentRefTimeMs(ScanResults results, TimeRange timeRange) { long refTimeInMs = results == null || timeRange.getStartTimeInMs() >= results.logSegmentForecastEndTimeMs || timeRange.getEndTimeInMs() < results.logSegmentForecastStartTimeMs ? REF_TIME_OUT_OF_BOUNDS : timeRange.getEndTimeInMs(); if (refTimeInMs != REF_TIME_OUT_OF_BOUNDS && refTimeInMs >= results.logSegmentForecastEndTimeMs) { refTimeInMs = results.logSegmentLastBucketTimeMs; } return refTimeInMs; }
Source:
<code><START> public void close() throws IOException <END> { final File outFile = IndexIO.makeMetricFile(outDir, metricName, IndexIO.BYTE_ORDER); close(outFile); }</code><technical_language>call this method else</technical_language>

Target:
public void close() throws IOException { final File outFile = IndexIO.makeMetricFile(outDir, metricName, IndexIO.BYTE_ORDER); closeFile(outFile); }
Source:
<code>public int parseArgs(final String[] args) throws ParseException { final CommandLineParser parser = new GnuParser(); final CommandLine command = parser.parse(options, args); if (command.hasOption("help")) { return 1; } if (command.hasOption("properties")) { this.properties = parseProperties(command.getOptionValue("properties")); } String defaultValue; <START> defaultValue = properties == null ? "null" : properties.getProperty("aeron.tools.mediadriver.sender"); <END> senderIdleStrategy = parseIdleStrategy(command.getOptionValue("sender", defaultValue)); defaultValue = properties == null ? "null" : properties.getProperty("aeron.tools.mediadriver.receiver"); receiverIdleStrategy = parseIdleStrategy(command.getOptionValue("receiver", defaultValue)); defaultValue = properties == null ? "null" : properties.getProperty("aeron.tools.mediadriver.network"); sharedNetworkIdleStrategy = parseIdleStrategy(command.getOptionValue("network", defaultValue)); defaultValue = properties == null ? "null" : properties.getProperty("aeron.tools.mediadriver.shared"); sharedIdleStrategy = parseIdleStrategy(command.getOptionValue("shared", defaultValue)); defaultValue = properties == null ? "null" : properties.getProperty("aeron.tools.mediadriver.conductor"); conductorIdleStrategy = parseIdleStrategy(command.getOptionValue("conductor", defaultValue)); return 0; }</code><technical_language>This feels simpler cleaner. While I works, is a bit hard follow. I feel @mjpt777 twitching</technical_language>

Target:
public int parseArgs(final String[] args) throws ParseException { final CommandLineParser parser = new GnuParser(); final CommandLine command = parser.parse(options, args); if (command.hasOption("help")) { return 1; } String senderValue = NULL_VALUE; String receiverValue = NULL_VALUE; String sharedNetworkValue = NULL_VALUE; String sharedValue = NULL_VALUE; String conductorValue = NULL_VALUE; if (command.hasOption("properties")) { this.properties = parseProperties(command.getOptionValue("properties")); senderValue = properties.getProperty("aeron.tools.mediadriver.sender"); receiverValue = properties.getProperty("aeron.tools.mediadriver.receiver"); sharedNetworkValue = properties.getProperty("aeron.tools.mediadriver.network"); sharedValue = properties.getProperty("aeron.tools.mediadriver.shared"); conductorValue = properties.getProperty("aeron.tools.mediadriver.conductor"); } senderIdleStrategy = parseIdleStrategy(command.getOptionValue("sender", senderValue)); receiverIdleStrategy = parseIdleStrategy(command.getOptionValue("receiver", receiverValue)); sharedNetworkIdleStrategy = parseIdleStrategy(command.getOptionValue("network", sharedNetworkValue)); sharedIdleStrategy = parseIdleStrategy(command.getOptionValue("shared", sharedValue)); conductorIdleStrategy = parseIdleStrategy(command.getOptionValue("conductor", conductorValue)); return 0; }
Source:
<code>public int compare(String o1, String o2) { <START> if (Objects.equals(o1, o2)) { <END> return 0; } if (o1 == null) { return -1; } if (o2 == null) { return 1; } Long long1 = GuavaUtils.tryParseLong(o1); Long long2 = GuavaUtils.tryParseLong(o2); if (long1 != null && long2 != null) { return Long.compare(long1, long2); } final BigDecimal bd1 = long1 == null ? convertStringToBigDecimal(o1) : new BigDecimal(long1); final BigDecimal bd2 = long2 == null ? convertStringToBigDecimal(o2) : new BigDecimal(long2); if (bd1 != null && bd2 != null) { return bd1.compareTo(bd2); } if (bd1 == null && bd2 == null) { return StringComparators.LEXICOGRAPHIC.compare(o1, o2); } if (bd1 == null) { return -1; } else { return 1; } }</code><technical_language>Similar question: is this better</technical_language>

Target:
public int compare(String o1, String o2) { if (o1 == o2) { return 0; } if (o1 == null) { return -1; } if (o2 == null) { return 1; } Long long1 = GuavaUtils.tryParseLong(o1); Long long2 = GuavaUtils.tryParseLong(o2); if (long1 != null && long2 != null) { return Long.compare(long1, long2); } final BigDecimal bd1 = long1 == null ? convertStringToBigDecimal(o1) : new BigDecimal(long1); final BigDecimal bd2 = long2 == null ? convertStringToBigDecimal(o2) : new BigDecimal(long2); if (bd1 != null && bd2 != null) { return bd1.compareTo(bd2); } if (bd1 == null && bd2 == null) { return StringComparators.LEXICOGRAPHIC.compare(o1, o2); } if (bd1 == null) { return -1; } else { return 1; } }
Source:
<code>private String prepareMessageFormatPattern(int invocationIndex, Arguments arguments) { String result = namePattern.replace("{index}", String.valueOf(invocationIndex)); result = result.replace("{arguments.description}", arguments.description()); if (result.contains("{arguments}")) { <START> String replacement = IntStream.range(0, arguments.get().length) <END> .mapToObj(index -> "{" + index + "}") .collect(joining(", ")); result = result.replace("{arguments}", replacement); } return result; }</code><technical_language>avoid calling get() multiple times costly compute array</technical_language>

Target:
private String prepareMessageFormatPattern(int invocationIndex, Arguments arguments) { String result = namePattern.replace("{index}", String.valueOf(invocationIndex)); result = result.replace("{arguments.description}", arguments.getDescription().orElse("")); if (result.contains("{arguments}")) { String replacement = IntStream.range(0, arguments.size()) .mapToObj(index -> "{" + index + "}") .collect(joining(", ")); result = result.replace("{arguments}", replacement); } return result; }
Source:
<code>public static void remarkTransientFields(Class targetClass) { try { BeanInfo info; info = Introspector.getBeanInfo(targetClass); PropertyDescriptor[] propertyDescriptors = info.getPropertyDescriptors(); for (Field f : Project.class.getDeclaredFields()) { if (Modifier.isTransient(f.getModifiers())) { for (int i = 0; i < propertyDescriptors.length; ++i) { if (propertyDescriptors[i].getName().equals(f.getName())) { propertyDescriptors[i].setValue("transient", Boolean.TRUE); } } } } <START> } catch (IntrospectionException ex) { <END> } }</code><technical_language>log this</technical_language>

Target:
public static void remarkTransientFields(Class targetClass) { try { BeanInfo info; info = Introspector.getBeanInfo(targetClass); PropertyDescriptor[] propertyDescriptors = info.getPropertyDescriptors(); for (Field f : Project.class.getDeclaredFields()) { if (Modifier.isTransient(f.getModifiers())) { for (int i = 0; i < propertyDescriptors.length; ++i) { if (propertyDescriptors[i].getName().equals(f.getName())) { propertyDescriptors[i].setValue("transient", Boolean.TRUE); } } } } } catch (IntrospectionException ex) { LOGGER.log(Level.WARNING, "An exception ocurred during remarking transient fields:", ex); } }
Source:
<code>Mono<Response<String>> startCopyFromURLWithResponse(URL sourceURL, Metadata metadata, ModifiedAccessConditions sourceModifiedAccessConditions, BlobAccessConditions destAccessConditions, Context context) { metadata = metadata == null ? new Metadata() : metadata; sourceModifiedAccessConditions = sourceModifiedAccessConditions == null ? new ModifiedAccessConditions() : sourceModifiedAccessConditions; destAccessConditions = destAccessConditions == null ? new BlobAccessConditions() : destAccessConditions; SourceModifiedAccessConditions sourceConditions = new SourceModifiedAccessConditions() .sourceIfModifiedSince(sourceModifiedAccessConditions.ifModifiedSince()) .sourceIfUnmodifiedSince(sourceModifiedAccessConditions.ifUnmodifiedSince()) .sourceIfMatch(sourceModifiedAccessConditions.ifMatch()) <START> .sourceIfNoneMatch(sourceModifiedAccessConditions.ifNoneMatch()); <END> return postProcessResponse(this.azureBlobStorage.blobs().startCopyFromURLWithRestResponseAsync( null, null, sourceURL, null, metadata, null, sourceConditions, destAccessConditions.modifiedAccessConditions(), destAccessConditions.leaseAccessConditions(), context)) .map(rb -> new SimpleResponse<>(rb, rb.deserializedHeaders().copyId())); }</code><technical_language>This kind of horizontal shuffling reverted</technical_language>

Target:
Mono<Response<String>> startCopyFromURLWithResponse(URL sourceURL, Metadata metadata, ModifiedAccessConditions sourceModifiedAccessConditions, BlobAccessConditions destAccessConditions, Context context) { metadata = metadata == null ? new Metadata() : metadata; sourceModifiedAccessConditions = sourceModifiedAccessConditions == null ? new ModifiedAccessConditions() : sourceModifiedAccessConditions; destAccessConditions = destAccessConditions == null ? new BlobAccessConditions() : destAccessConditions; SourceModifiedAccessConditions sourceConditions = new SourceModifiedAccessConditions() .sourceIfModifiedSince(sourceModifiedAccessConditions.ifModifiedSince()) .sourceIfUnmodifiedSince(sourceModifiedAccessConditions.ifUnmodifiedSince()) .sourceIfMatch(sourceModifiedAccessConditions.ifMatch()) .sourceIfNoneMatch(sourceModifiedAccessConditions.ifNoneMatch()); return postProcessResponse(this.azureBlobStorage.blobs().startCopyFromURLWithRestResponseAsync( null, null, sourceURL, null, metadata, null, null, null, null, sourceConditions, destAccessConditions.modifiedAccessConditions(), destAccessConditions.leaseAccessConditions(), context)) .map(rb -> new SimpleResponse<>(rb, rb.deserializedHeaders().copyId())); }
Source:
<code>public void visitFunction(GoloFunction function) { resetIndexAssignmentCounter(); <START> if(function.isNative()) return; <END> ReferenceTable table = function.getBlock().getReferenceTable(); for (String parameterName : function.getParameterNames()) { LocalReference reference = table.get(parameterName); if (reference == null) { throw new IllegalStateException("[please report this bug] " + parameterName + " is not declared in the references of function " + function.getName()); } reference.setIndex(nextAssignmentIndex()); } function.getBlock().accept(this); }</code><technical_language>blocks! :-)</technical_language>

Target:
public void visitFunction(GoloFunction function) { resetIndexAssignmentCounter(); if(function.isNative()) { return; } ReferenceTable table = function.getBlock().getReferenceTable(); for (String parameterName : function.getParameterNames()) { LocalReference reference = table.get(parameterName); if (reference == null) { throw new IllegalStateException("[please report this bug] " + parameterName + " is not declared in the references of function " + function.getName()); } reference.setIndex(nextAssignmentIndex()); } function.getBlock().accept(this); }
Source:
<code>public static AccountCollection all(Map<String, Object> params) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException { <START> return request(RequestMethod.GET, classURL(Account.class), params, AccountCollection.class, (RequestOptions) null); <END> }</code><technical_language>This call java return all(params, (RequestOptions) null);</technical_language>

Target:
public static AccountCollection all(Map<String, Object> params) throws AuthenticationException, InvalidRequestException, APIConnectionException, CardException, APIException { return all(params, (RequestOptions) null); }
Source:
<code>private void initHost() { loadProcesses.add(new RegisterMods(gameManifest)); loadProcesses.add(new CacheTextures()); loadProcesses.add(new RegisterBlockFamilyFactories()); loadProcesses.add(new RegisterBlocks(gameManifest)); loadProcesses.add(new CacheBlocks()); loadProcesses.add(new InitialiseGraphics()); loadProcesses.add(new InitialiseEntitySystem()); loadProcesses.add(new LoadPrefabs()); loadProcesses.add(new ProcessBlockPrefabs()); loadProcesses.add(new RegisterInputSystem()); loadProcesses.add(new RegisterSystems(netMode)); loadProcesses.add(new InitialiseCommandSystem()); <START> loadProcesses.add(new CreateWorldEntity()); <END> loadProcesses.add(new InitialiseWorld(gameManifest)); loadProcesses.add(new InitialiseSystems()); loadProcesses.add(new LoadEntities()); loadProcesses.add(new InitialiseBlockTypeEntities()); if (netMode == NetworkMode.SERVER) { loadProcesses.add(new StartServer()); } loadProcesses.add(new SetupLocalPlayer()); loadProcesses.add(new AwaitCharacterSpawn()); loadProcesses.add(new PrepareWorld()); }</code><technical_language>is issue here, this needs occur load entities - multiple world entities/losing changes</technical_language>

Target:
private void initHost() { loadProcesses.add(new RegisterMods(gameManifest)); loadProcesses.add(new CacheTextures()); loadProcesses.add(new RegisterBlockFamilyFactories()); loadProcesses.add(new RegisterBlocks(gameManifest)); loadProcesses.add(new CacheBlocks()); loadProcesses.add(new InitialiseGraphics()); loadProcesses.add(new InitialiseEntitySystem()); loadProcesses.add(new LoadPrefabs()); loadProcesses.add(new ProcessBlockPrefabs()); loadProcesses.add(new RegisterInputSystem()); loadProcesses.add(new RegisterSystems(netMode)); loadProcesses.add(new InitialiseCommandSystem()); loadProcesses.add(new InitialiseWorld(gameManifest)); loadProcesses.add(new InitialiseSystems()); loadProcesses.add(new LoadEntities()); loadProcesses.add(new InitialiseBlockTypeEntities()); loadProcesses.add(new CreateWorldEntity()); if (netMode == NetworkMode.SERVER) { loadProcesses.add(new StartServer()); } loadProcesses.add(new SetupLocalPlayer()); loadProcesses.add(new AwaitCharacterSpawn()); loadProcesses.add(new PrepareWorld()); }
Source:
<code>private void deleteGroup(Object id) { Group group = dataService.findOneById(GroupMetadata.GROUP, id, Group.class); List<Role> roles = <START> dataService <END> .findAll( RoleMetadata.ROLE, new QueryImpl<Role>().eq(RoleMetadata.GROUP, id), Role.class) .collect(Collectors.toList()); roles.forEach(this::removeMembers); dataService.delete(RoleMetadata.ROLE, roles.stream()); delegate().deleteById(id); mutableAclService.deleteAcl(new GroupIdentity(group.getName()), true); }</code><technical_language>dataService.query(...).eq(..) is default syntax nowadays (?)</technical_language>

Target:
private void deleteGroup(Object id) { Group group = dataService.findOneById(GroupMetadata.GROUP, id, Group.class); Iterable<Role> roles = group.getRoles(); roles.forEach(this::removeMembers); dataService.delete(RoleMetadata.ROLE, StreamSupport.stream(roles.spliterator(), false)); delegate().deleteById(id); mutableAclService.deleteAcl(new GroupIdentity(group.getName()), true); }
Source:
<code>public static <T> T readObjectFromConfAsBase64(String key, Configuration conf) throws IOException { String b64 = conf.get(key); if (b64 == null) { return null; } byte[] bytes = Base64.decodeBase64(b64.getBytes("UTF-8")); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); try { return (T) ois.readObject(); } catch (ClassNotFoundException e) { LOG.error("Could not read object from config with key " + key, e); throw new IOException(e); } catch (ClassCastException e) { LOG.error("Couldn't cast object read from config with key " + key, e); <START> throw new IOException(e); <END> } }</code><technical_language>In general if throw exception log error (or logged twice, here, exception is caught). Instead add log message in exception throw. throw new IOException("Couldn't cast object read config key " + key,e);</technical_language>

Target:
public static <T> T readObjectFromConfAsBase64(String key, Configuration conf) throws IOException { String b64 = conf.get(key); if (b64 == null) { return null; } byte[] bytes = Base64.decodeBase64(b64.getBytes("UTF-8")); ByteArrayInputStream bais = null; GZIPInputStream gis = null; ObjectInputStream ois = null; try { bais = new ByteArrayInputStream(bytes); gis = new GZIPInputStream(bais); ois = new ObjectInputStream(gis); return (T) ois.readObject(); } catch (ClassNotFoundException e) { throw new IOException("Could not read object from config with key " + key, e); } catch (ClassCastException e) { throw new IOException("Couldn't cast object read from config with key " + key, e); } finally { Closeables.close(ois); Closeables.close(gis); Closeables.close(bais); } }