auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public UserExtSource getUserExtSourceFromMultipleIdentifiers(PerunSession sess, PerunPrincipal principal) throws InternalErrorException, UserExtSourceNotExistsException, WrongReferenceAttributeValueException { String additionalIdentifiers = principal.getAdditionalInformations().get(additionalIdentifiersAttributeName); if (additionalIdentifiers == null) { <START> throw new WrongReferenceAttributeValueException("Principal's mandatory attribute is not defined: ".concat(additionalIdentifiersAttributeName)); <END> } UserExtSource ues = null; for(String identifier : additionalIdentifiers.split(multivalueAttributeSeparatorRegExp)) { try { ues = perunBl.getUsersManagerBl().getUserExtSourceByUniqueAttributeValue(sess, additionalIdentifiersPerunAttributeName, identifier); log.debug("UserExtSource found using additional identifiers: " + ues); break; } catch (UserExtSourceNotExistsException ex) { } catch (InternalErrorException | AttributeNotExistsException ex) { String errorMessage = "Mandatory attribute is not defined: ".concat(additionalIdentifiersPerunAttributeName); log.error(errorMessage); throw new InternalErrorException(errorMessage, ex); } } if (ues == null) throw new UserExtSourceNotExistsException("User ext source was not found. Searched value is any from \"" + additionalIdentifiers + "\" in " + additionalIdentifiersPerunAttributeName); return ues; }</code><technical_language>this is a configuration error? InternalErrorException</technical_language>

Target:
public UserExtSource getUserExtSourceFromMultipleIdentifiers(PerunSession sess, PerunPrincipal principal) throws UserExtSourceNotExistsException { String additionalIdentifiers = principal.getAdditionalInformations().get(additionalIdentifiersAttributeName); if (additionalIdentifiers == null) { throw new InternalErrorException("Entry " + additionalIdentifiersAttributeName + " is not defined in the principal's additional information. Either it was not provided by external source used for sign-in or the mapping configuration is wrong."); } UserExtSource ues = null; for(String identifier : additionalIdentifiers.split(multivalueAttributeSeparatorRegExp)) { try { ues = perunBl.getUsersManagerBl().getUserExtSourceByUniqueAttributeValue(sess, additionalIdentifiersPerunAttributeName, identifier); log.debug("UserExtSource found using additional identifiers: " + ues); break; } catch (UserExtSourceNotExistsException ex) { } catch (AttributeNotExistsException ex) { String errorMessage = "Mandatory attribute is not defined: ".concat(additionalIdentifiersPerunAttributeName); log.error(errorMessage); throw new InternalErrorException(errorMessage, ex); } } if (ues == null) throw new UserExtSourceNotExistsException("User ext source was not found. Searched value is any from \"" + additionalIdentifiers + "\" in " + additionalIdentifiersPerunAttributeName); return ues; }
Source:
<code>final public Set<SchoolClass> getSchoolClassesToEnrolBy(final ExecutionCourse executionCourse) { <START> Set<SchoolClass> schoolClasses = getActiveStudentCurricularPlan() != null ? executionCourse <END> .getSchoolClassesBy(getActiveStudentCurricularPlan().getDegreeCurricularPlan()) : new HashSet<SchoolClass>(); return schoolClasses.isEmpty() ? executionCourse.getSchoolClasses() : schoolClasses; }</code><technical_language>Avoid calling getActiveStudentCurricularPlan() multiple times in method. Invoking method multiple times results in a performance penalty avoided</technical_language>

Target:
final public Set<SchoolClass> getSchoolClassesToEnrolBy(final ExecutionCourse executionCourse) { StudentCurricularPlan scp = getActiveStudentCurricularPlan(); Set<SchoolClass> schoolClasses = scp != null ? executionCourse .getSchoolClassesBy(scp.getDegreeCurricularPlan()) : new HashSet<SchoolClass>(); return schoolClasses.isEmpty() ? executionCourse.getSchoolClasses() : schoolClasses; }
Source:
<code>public CookieFilter(CookieSpec cookieSpec) { <START> this.cookieSpec = cookieSpec; <END> this.allowMultipleCookiesWithTheSameName = false; this.cookieStore = new BasicCookieStore(); }</code><technical_language>re-use existing constructors: this(cookieSpec, false);</technical_language>

Target:
public CookieFilter(CookieSpec cookieSpec) { this(cookieSpec, false); }
Source:
<code>protected List<Class<?>> getModelAdapters() { return new ArrayList<>(Arrays.asList( SteppingController.class, IViewerInputProvider.class, ISteppingModeTarget.class, ISourceDisplay.class, IStepIntoHandler.class, IStepIntoSelectionHandler.class, IReverseStepIntoHandler.class, IStepOverHandler.class, IReverseStepOverHandler.class, IStepReturnHandler.class, IUncallHandler.class, ISuspendHandler.class, IResumeHandler.class, IReverseResumeHandler.class, IResumeWithoutSignalHandler.class, IRestartHandler.class, ITerminateHandler.class, IDebugNewExecutableHandler.class, IConnectHandler.class, IDisconnectHandler.class, IModelSelectionPolicyFactory.class, IRefreshAllTarget.class, <START> IChangeReverseMethodHandler.class, <END> IStartTracingHandler.class, IStopTracingHandler.class, ISaveTraceDataHandler.class, ISelectNextTraceRecordHandler.class, ISelectPrevTraceRecordHandler.class, IPinProvider.class, IDebugModelProvider.class, ILaunch.class, ICEditorTextHover.class)); }</code><technical_language>This needs remain IReverseToggleHandler for other changes break things</technical_language>

Target:
protected List<Class<?>> getModelAdapters() { return new ArrayList<>(Arrays.asList( SteppingController.class, IViewerInputProvider.class, ISteppingModeTarget.class, ISourceDisplay.class, IStepIntoHandler.class, IStepIntoSelectionHandler.class, IReverseStepIntoHandler.class, IStepOverHandler.class, IReverseStepOverHandler.class, IStepReturnHandler.class, IUncallHandler.class, ISuspendHandler.class, IResumeHandler.class, IReverseResumeHandler.class, IResumeWithoutSignalHandler.class, IRestartHandler.class, ITerminateHandler.class, IDebugNewExecutableHandler.class, IConnectHandler.class, IDisconnectHandler.class, IModelSelectionPolicyFactory.class, IRefreshAllTarget.class, IReverseToggleHandler.class, IStartTracingHandler.class, IStopTracingHandler.class, ISaveTraceDataHandler.class, ISelectNextTraceRecordHandler.class, ISelectPrevTraceRecordHandler.class, IPinProvider.class, IDebugModelProvider.class, ILaunch.class, ICEditorTextHover.class)); }
Source:
<code>public void updateMessageView(View view){ if (view == null ) view = getView(); if ( view == null ) return; TextView messageView = (TextView) view.findViewById(R.id.no_chapter_tv); if(adapter.getCount()==0){ messageView.setVisibility(View.VISIBLE); if ( adapter.hasFilteredUnits() ){ Context context = getActivity(); Drawable modeSwitcherDrawable = new IconDrawable(context, FontAwesomeIcons.fa_list) .colorRes(context, R.color.edx_grayscale_neutral_light) <START> .sizeDp(context, 80); <END> messageView.setCompoundDrawablesWithIntrinsicBounds( null, modeSwitcherDrawable, null, null); Resources resources = getResources(); messageView.setText(ResourceUtil.getFormattedString(resources, R.string.assessment_empty_video_info, "mode_switcher", '{' + FontAwesomeIcons.fa_list.key() + " baseline}")); messageView.setContentDescription(ResourceUtil.getFormattedString(resources, R.string.assessment_empty_video_info, "mode_switcher", getText(R.string.course_change_mode))); } else { messageView.setCompoundDrawables(null, null, null, null); messageView.setText(R.string.no_chapter_text); messageView.setContentDescription(null); } }else{ messageView.setVisibility(View.GONE); } }</code><technical_language>is 80 a standard size a dimen resource</technical_language>

Target:
public void updateMessageView(View view){ if (view == null ) view = getView(); if ( view == null ) return; TextView messageView = (TextView) view.findViewById(R.id.no_chapter_tv); if(adapter.getCount()==0){ messageView.setVisibility(View.VISIBLE); if ( adapter.hasFilteredUnits() ){ Context context = getActivity(); Drawable modeSwitcherDrawable = new IconDrawable(context, FontAwesomeIcons.fa_list) .colorRes(context, R.color.edx_grayscale_neutral_light) .sizeRes(context, R.dimen.empty_list_icon_size); messageView.setCompoundDrawablesWithIntrinsicBounds( null, modeSwitcherDrawable, null, null); Resources resources = getResources(); messageView.setText(ResourceUtil.getFormattedString(resources, R.string.assessment_empty_video_info, "mode_switcher", '{' + FontAwesomeIcons.fa_list.key() + " baseline}")); messageView.setContentDescription(ResourceUtil.getFormattedString(resources, R.string.assessment_empty_video_info, "mode_switcher", getText(R.string.course_change_mode))); } else { messageView.setCompoundDrawables(null, null, null, null); messageView.setText(R.string.no_chapter_text); messageView.setContentDescription(null); } }else{ messageView.setVisibility(View.GONE); } }
Source:
<code>public Map<String, ByteBuffer> getOperatorState() throws IOException { <START> final Map<String, ByteBuffer> fizedSizeWindowStateMap = super.getOperatorState(); <END> fizedSizeWindowStateMap.put("count", StateSerializer.serializeState(count)); return fizedSizeWindowStateMap; }</code><technical_language>helpful</technical_language>

Target:
public Map<String, Object> getOperatorState() { final Map<String, Object> stateMap = super.getOperatorState(); stateMap.put("count", count); return stateMap; }
Source:
<code>public void stopMachine(String workspaceId, String machineId) throws NotFoundException, ServerException, ConflictException { Instance targetMachine = null; try (StripedLocks.WriteLock lock = stripedLocks.acquireWriteLock(workspaceId)) { EnvironmentHolder environmentHolder = environments.get(workspaceId); if (environmentHolder == null || environmentHolder.status != EnvStatus.RUNNING) { throw new ConflictException(format("Environment '%s' is not running", workspaceId)); } <START> for (Instance machine : environmentHolder.machines) { <END> if (machine.getId().equals(machineId)) { if (machine.getConfig().isDev()) { throw new ConflictException( "Stop of dev machine is not allowed. Please, stop whole environment"); } targetMachine = machine; break; } } environmentHolder.machines.remove(targetMachine); } if (targetMachine == null) { throw new NotFoundException(format("Machine with ID '%s' is not found in environment of workspace '%s'", machineId, workspaceId)); } eventService.publish(newDto(MachineStatusEvent.class) .withEventType(MachineStatusEvent.EventType.DESTROYING) .withDev(targetMachine.getConfig().isDev()) .withMachineName(targetMachine.getConfig().getName()) .withMachineId(machineId) .withWorkspaceId(workspaceId)); targetMachine.destroy(); eventService.publish(newDto(MachineStatusEvent.class) .withEventType(MachineStatusEvent.EventType.DESTROYED) .withDev(targetMachine.getConfig().isDev()) .withMachineName(targetMachine.getConfig().getName()) .withMachineId(machineId) .withWorkspaceId(workspaceId)); }</code><technical_language>simplify this code reusing removeFirstMatching method</technical_language>

Target:
public void stopMachine(String workspaceId, String machineId) throws NotFoundException, ServerException, ConflictException { Instance targetMachine = null; try (StripedLocks.WriteLock lock = stripedLocks.acquireWriteLock(workspaceId)) { EnvironmentHolder environmentHolder = environments.get(workspaceId); if (environmentHolder == null || environmentHolder.status != EnvStatus.RUNNING) { throw new EnvironmentNotRunningException(format("Environment '%s' is not running", workspaceId)); } for (Instance machine : environmentHolder.machines) { if (machine.getId().equals(machineId)) { if (machine.getConfig().isDev()) { throw new ConflictException( "Stop of dev machine is not allowed. Please, stop whole environment"); } targetMachine = machine; break; } } environmentHolder.machines.remove(targetMachine); } if (targetMachine == null) { throw new NotFoundException(format("Machine with ID '%s' is not found in environment of workspace '%s'", machineId, workspaceId)); } eventService.publish(newDto(MachineStatusEvent.class) .withEventType(MachineStatusEvent.EventType.DESTROYING) .withDev(targetMachine.getConfig().isDev()) .withMachineName(targetMachine.getConfig().getName()) .withMachineId(machineId) .withWorkspaceId(workspaceId)); targetMachine.destroy(); eventService.publish(newDto(MachineStatusEvent.class) .withEventType(MachineStatusEvent.EventType.DESTROYED) .withDev(targetMachine.getConfig().isDev()) .withMachineName(targetMachine.getConfig().getName()) .withMachineId(machineId) .withWorkspaceId(workspaceId)); }
Source:
<code>private static Optional<InetAddress> toValidAddress(InetAddress address) { if (address instanceof Inet6Address) { Inet6Address v6Address = (Inet6Address) address; if (isValidV6Address(v6Address)) { return Optional.ofNullable(normalizeV6Address(v6Address)); } } <START> if (isValidAddress(address)) { <END> return Optional.of(address); } return Optional.empty(); }</code><technical_language>refactor method name isValidAddress **isValidV4Address**. do say</technical_language>

Target:
private static Optional<InetAddress> toValidAddress(InetAddress address) { if (address instanceof Inet6Address) { Inet6Address v6Address = (Inet6Address) address; if (isValidV6Address(v6Address)) { return Optional.ofNullable(normalizeV6Address(v6Address)); } } if (isValidV4Address(address)) { return Optional.of(address); } return Optional.empty(); }
Source:
<code>public void render(Context context, GlusterVolumeEntity volume, SafeHtmlBuilder sb) { if (volume == null) { return; } int brickCount = volume.getBricks().size(); int count = 0; GlusterStatus status = volume.getStatus(); ImageResource statusImage = null; String tooltip; switch (status) { case DOWN: statusImage = resources.downImage(); tooltip = constants.down(); break; case UP: count = countDownBricks(volume); if(count == 0){ statusImage = resources.upImage(); tooltip = constants.up(); } else if(count < brickCount) { statusImage = resources.volumeBricksDownWarning(); tooltip = constants.volumeBricksDown(); } else { statusImage = resources.volumeAllBricksDownWarning(); tooltip = constants.volumeAllBricksDown(); } break; default: statusImage = resources.downImage(); tooltip = constants.down(); } <START> ImageResource alertImage = resources.alertImage(); <END> SafeHtml statusImageHtml = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(statusImage).getHTML()); sb.append(applicationTemplates.statusTemplate(statusImageHtml, tooltip)); }</code><technical_language>is extra indentation in lines, please remove them. alertImage is used</technical_language>

Target:
public void render(Context context, GlusterVolumeEntity volume, SafeHtmlBuilder sb) { if (volume == null) { return; } int brickCount = volume.getBricks().size(); int count = 0; GlusterStatus status = volume.getStatus(); ImageResource statusImage = null; String tooltip; switch (status) { case DOWN: statusImage = resources.downImage(); tooltip = constants.down(); break; case UP: count = countDownBricks(volume); if (count == 0) { statusImage = resources.upImage(); tooltip = constants.up(); } else if (count < brickCount) { statusImage = resources.volumeBricksDownWarning(); tooltip = constants.volumeBricksDown(); } else { statusImage = resources.volumeAllBricksDownWarning(); tooltip = constants.volumeAllBricksDown(); } break; default: statusImage = resources.downImage(); tooltip = constants.down(); } SafeHtml statusImageHtml = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(statusImage).getHTML()); sb.append(applicationTemplates.statusTemplate(statusImageHtml, tooltip)); }
Source:
<code>public void testBusinessRuleTaskFireLimitAsParameter() throws Exception { KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-BusinessRuleTaskWithDataInputLoop.bpmn2", "BPMN2-BusinessRuleTaskInfiniteLoop.drl"); ksession = createKnowledgeSession(kbase); ksession.insert(new Person()); Map<String, Object> parameters = new HashMap<>(); <START> parameters.put("limit", 5); <END> assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> { ksession.startProcess("BPMN2-BusinessRuleTask", parameters); }) .withMessageContaining("Fire rule limit reached 5"); }</code><technical_language>consider Collections.singletonMap() for slightly nicer code</technical_language>

Target:
public void testBusinessRuleTaskFireLimitAsParameter() throws Exception { KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-BusinessRuleTaskWithDataInputLoop.bpmn2", "BPMN2-BusinessRuleTaskInfiniteLoop.drl"); ksession = createKnowledgeSession(kbase); ksession.insert(new Person()); Map<String, Object> parameters = Collections.singletonMap("limit", 5); assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> { ksession.startProcess("BPMN2-BusinessRuleTask", parameters); }) .withMessageContaining("Fire rule limit reached 5"); }
Source:
<code>public void hotSwapScript(Node scriptRoot, Node originalRoot) { if (!isModuleFile(scriptRoot)) return; Node block = IR.block(); block.addChildToBack(IR.exprResult(IR.string("use strict"))); for (Node c = scriptRoot.getFirstChild(); c != null; c = c.getNext()) { <START> block.addChildToBack(c.cloneTree()); <END> } block.addChildToBack(IR.returnNode(IR.name("exports"))); Node loadMod = IR.exprResult(IR.call( IR.getprop(IR.name("goog"), IR.string("loadModule")), IR.function(IR.name(""), IR.paramList(IR.name("exports")), block))); scriptRoot.removeChildren(); scriptRoot.addChildToBack(loadMod); compiler.reportCodeChange(); }</code><technical_language>I need clone entire trees here. detaching enough</technical_language>

Target:
public void hotSwapScript(Node scriptRoot, Node originalRoot) { if (!NodeUtil.isModuleFile(scriptRoot)) return; Node block = IR.block(); block.addChildToBack(IR.exprResult(IR.string("use strict"))); Node loadMod = IR.exprResult(IR.call( IR.getprop(IR.name("goog"), IR.string("loadModule")), IR.function(IR.name(""), IR.paramList(IR.name("exports")), block))) .srcrefTree(scriptRoot); if (scriptRoot.hasChildren()) { block.addChildrenToBack(scriptRoot.removeChildren()); } block.addChildToBack(IR.returnNode(IR.name("exports")).srcrefTree(scriptRoot)); scriptRoot.addChildToBack(loadMod); compiler.reportCodeChange(); }
Source:
<code>public String showUserPage(@Context HttpServletRequest request, @PathParam("netId") String netId) throws IOException, ApiError { Map<String, Object> parameters = Maps.newHashMap(); parameters.put("user", currentUser); parameters.put("path", request.getRequestURI()); <START> parameters.put("notifications", currentUser.getNotifications()); <END> List<Locale> locales = Collections.list(request.getLocales()); return templateEngine.process("notifications.ftl", locales, parameters); }</code><technical_language>TODO: Limit n notifications</technical_language>

Target:
public String showUserPage(@Context HttpServletRequest request, @PathParam("netId") String netId) throws IOException, ApiError, URISyntaxException { return showPersonalUserPage(request); }
Source:
<code>public static Iterable<Reference> getReferences(String referenceSetId, GenomicsFactory.OfflineAuth auth) throws IOException, GeneralSecurityException { Genomics genomics = auth.getGenomics(auth.getDefaultFactory()); <START> Iterable<Reference> references = Paginator.References.create( <END> genomics).search(new SearchReferencesRequest().setReferenceSetId(referenceSetId)); return references; }</code><technical_language>Local variable unnecessary here</technical_language>

Target:
public static Iterable<Reference> getReferences(String referenceSetId, GenomicsFactory.OfflineAuth auth) throws IOException, GeneralSecurityException { Genomics genomics = auth.getGenomics(auth.getDefaultFactory()); return Paginator.References.create( genomics).search(new SearchReferencesRequest().setReferenceSetId(referenceSetId)); }
Source:
<code>public LagPortStats(final ByteBuf buffer) throws InvalidPacketException { this.dot3adAggPortActorSystemID = new Mac(buffer); this.dot3adAggPortPartnerOperSystemID = new Mac(buffer); this.dot3adAggPortAttachedAggID = BufferUtils.uint32(buffer); <START> this.dot3adAggPortState = new Opaque(buffer, Optional.of(4), buffer1 -> Opaque.parseBytes(buffer1)); <END> this.dot3adAggPortStatsLACPDUsRx = BufferUtils.uint32(buffer); this.dot3adAggPortStatsMarkerPDUsRx = BufferUtils.uint32(buffer); this.dot3adAggPortStatsMarkerResponsePDUsRx = BufferUtils.uint32(buffer); this.dot3adAggPortStatsUnknownRx = BufferUtils.uint32(buffer); this.dot3adAggPortStatsIllegalRx = BufferUtils.uint32(buffer); this.dot3adAggPortStatsLACPDUsTx = BufferUtils.uint32(buffer); this.dot3adAggPortStatsMarkerPDUsTx = BufferUtils.uint32(buffer); this.dot3adAggPortStatsMarkerResponsePDUsTx = BufferUtils.uint32(buffer); }</code><technical_language>Revert this</technical_language>

Target:
public LagPortStats(final ByteBuf buffer) throws InvalidPacketException { this.dot3adAggPortActorSystemID = new Mac(buffer); this.dot3adAggPortPartnerOperSystemID = new Mac(buffer); this.dot3adAggPortAttachedAggID = BufferUtils.uint32(buffer); this.dot3adAggPortState = new Opaque(buffer, Optional.of(4), Opaque::parseBytes); this.dot3adAggPortStatsLACPDUsRx = BufferUtils.uint32(buffer); this.dot3adAggPortStatsMarkerPDUsRx = BufferUtils.uint32(buffer); this.dot3adAggPortStatsMarkerResponsePDUsRx = BufferUtils.uint32(buffer); this.dot3adAggPortStatsUnknownRx = BufferUtils.uint32(buffer); this.dot3adAggPortStatsIllegalRx = BufferUtils.uint32(buffer); this.dot3adAggPortStatsLACPDUsTx = BufferUtils.uint32(buffer); this.dot3adAggPortStatsMarkerPDUsTx = BufferUtils.uint32(buffer); this.dot3adAggPortStatsMarkerResponsePDUsTx = BufferUtils.uint32(buffer); }
Source:
<code>default Type getType() { <START> return new DefaultParameterizedType(null, List.class, Block.class); <END> }</code><technical_language>default type String.class I think</technical_language>

Target:
default Type getType() { return String.class; }
Source:
<code>public OpenUrlAction(DialogService dialogService, StateManager stateManager) { this.dialogService = dialogService; this.stateManager = stateManager; BooleanBinding fieldIsSet = ActionHelper.isFieldSetForSelectedEntry(StandardField.URL, stateManager) <START> .or(ActionHelper.isFieldSetForSelectedEntry(StandardField.DOI, stateManager) <END> .or(ActionHelper.isFieldSetForSelectedEntry(StandardField.URI, stateManager) .or(ActionHelper.isFieldSetForSelectedEntry(StandardField.EPRINT, stateManager)))); this.executable.bind(ActionHelper.needsEntriesSelected(1, stateManager).and(fieldIsSet)); }</code><technical_language>This written a bit more elegantly isAnyFieldSet method, right</technical_language>

Target:
public OpenUrlAction(DialogService dialogService, StateManager stateManager) { this.dialogService = dialogService; this.stateManager = stateManager; BooleanExpression fieldIsSet = ActionHelper.isAnyFieldSetForSelectedEntry( List.of(StandardField.URL, StandardField.DOI, StandardField.URI, StandardField.EPRINT), stateManager); this.executable.bind(ActionHelper.needsEntriesSelected(1, stateManager).and(fieldIsSet)); }
Source:
<code>public void run() { String resp; while(!Thread.interrupted() && !client.isClosed()) { try { if(inStream.ready() && (resp = bufIn.readLine()) != null) { responseMessageHandler.handleResponse(resp + "\n", comm); } } catch (SocketException e) { e.printStackTrace(); <START> System.exit(-1); <END> } catch (IOException e) { e.printStackTrace(); System.exit(-1); } } }</code><technical_language>This handled in some other closing software (is this if error occur in a separate thread in Netbeans?)</technical_language>

Target:
public void run() { String resp; while(!Thread.interrupted() && !client.isClosed()) { try { if(inStream.ready() && (resp = bufIn.readLine()) != null) { responseMessageHandler.handleResponse(resp + "\n", comm); } } catch (SocketException e) { e.printStackTrace(); return; } catch (IOException e) { e.printStackTrace(); return; } } }
Source:
<code>public ExportConfiguration getConfiguration(FormStatus form) { <START> return Optional.ofNullable(customConfigurations.get(form.getFormDefinition().getFormId())) <END> .orElse(ExportConfiguration.empty()) .fallingBackTo(defaultConfiguration, form); }</code><technical_language>Duplicated code. getFormId(form). Also, if/when change ExportConfiguration.fallingBackTo(), signature change ExportForms.getConfiguration() rolled back..</technical_language>

Target:
public ExportConfiguration getConfiguration(FormStatus form) { return Optional.ofNullable(customConfigurations.get(form.getFormDefinition().getFormId())) .orElse(ExportConfiguration.empty(form)) .fallingBackTo(defaultConfiguration); }
Source:
<code><START> LineTcpMeasurementEvent createRebalanceEvent(int fromThreadId, int toThreadId, String tableName) { <END> clear(); threadId = REBALANCE_EVENT_ID; rebalanceFromThreadId = fromThreadId; rebalanceToThreadId = toThreadId; rebalanceTableName = tableName; return this; }</code><technical_language>return is unused</technical_language>

Target:
void createRebalanceEvent(int fromThreadId, int toThreadId, String tableName) { clear(); threadId = REBALANCE_EVENT_ID; rebalanceFromThreadId = fromThreadId; rebalanceToThreadId = toThreadId; rebalanceTableName = tableName; }
Source:
<code>public LabelTypes getLabelTypes() { if (labels == null) { List<LabelType> all = getProjectControl().getLabelTypes().getLabelTypes(); <START> final Set<String> <END> labelNames = Sets.<String> newHashSetWithExpectedSize(all.size()); for (Map.Entry<String, List<PermissionRule>> p : relevant .getDeclaredPermissions()) { if (Permission.isLabel(p.getKey())) { labelNames.add(Permission.extractLabel(p.getKey())); } } List<LabelType> r = Lists.newArrayListWithCapacity(all.size()); for (LabelType l : all) { if (labelNames.contains(l.getName())) { r.add(l); } } labels = new LabelTypes(r); } return labels; }</code><technical_language>Unnecessary final</technical_language>

Target:
public LabelTypes getLabelTypes() { if (labels == null) { List<LabelType> all = getProjectControl().getLabelTypes().getLabelTypes(); Set<String> labelNames = Sets.<String> newHashSetWithExpectedSize(all.size()); for (Map.Entry<String, List<PermissionRule>> p : relevant .getDeclaredPermissions()) { if (Permission.isLabel(p.getKey())) { labelNames.add(Permission.extractLabel(p.getKey())); } } List<LabelType> r = Lists.newArrayListWithCapacity(all.size()); for (LabelType l : all) { if (labelNames.contains(l.getName())) { r.add(l); } } labels = new LabelTypes(r); } return labels; }
Source:
<code><START> public GetProvisioningStateResponseHandler(DateCodecFactory dateCodec) { <END> super(dateCodec); }</code><technical_language>constructor visibility thing</technical_language>

Target:
GetProvisioningStateResponseHandler(DateCodecFactory dateCodec) { super(dateCodec); }
Source:
<code>public ConsoleAnnotator<Object> annotate(Object context, MarkupText text) { Run<?, ?> build; if (context instanceof Run) { build = (Run<?, ?>) context; } else if (context instanceof FlowNode) { FlowExecutionOwner owner = ((FlowNode) context).getExecution().getOwner(); if (owner == null) { return null; } Queue.Executable executable; try { executable = owner.getExecutable(); } catch (IOException x) { LOGGER.log(Level.FINE, null, x); return null; } if (executable instanceof Run) { build = (Run) executable; } else { return null; } } else { return null; } long buildStartTime = build.getStartTimeInMillis(); String html = text.toString(true); int start; if (html.startsWith("<span class=\"pipeline-new-node\" ")) { start = html.indexOf('>') + 1; } else { start = 0; } if (html.startsWith("[", start)) { int end = html.indexOf(']', start); if (end != -1) { <START> Date date = GlobalDecorator.UTC_MILLIS.get().parse(html, new ParsePosition(start + 1)); <END> if (date != null) { long millisSinceEpoch = date.getTime(); Timestamp timestamp = new Timestamp(millisSinceEpoch - buildStartTime, millisSinceEpoch); TimestampFormat format = TimestampFormatProvider.get(); format.markup(text, timestamp); text.addMarkup(0, 26, "<span style=\"display: none\">", "</span>"); } } } return this; }</code><technical_language>suggestion Date date = Date.from(Instant.parse(html.substring(start + 1, end))); (Although Instant for increased precision.)</technical_language>

Target:
public ConsoleAnnotator<Object> annotate(Object context, MarkupText text) { Run<?, ?> build; if (context instanceof Run) { build = (Run<?, ?>) context; } else if (context instanceof FlowNode) { FlowExecutionOwner owner = ((FlowNode) context).getExecution().getOwner(); if (owner == null) { return null; } Queue.Executable executable; try { executable = owner.getExecutable(); } catch (IOException x) { LOGGER.log(Level.FINE, null, x); return null; } if (executable instanceof Run) { build = (Run) executable; } else { return null; } } else { return null; } long buildStartTime = build.getStartTimeInMillis(); String html = text.toString(true); int start; if (html.startsWith("<span class=\"pipeline-new-node\" ")) { start = html.indexOf('>') + 1; } else { start = 0; } if (html.startsWith("[", start)) { int end = html.indexOf(']', start); if (end != -1) { try { long millisSinceEpoch = ZonedDateTime.parse(html.substring(start + 1, end), GlobalDecorator.UTC_MILLIS).toInstant().toEpochMilli(); Timestamp timestamp = new Timestamp(millisSinceEpoch - buildStartTime, millisSinceEpoch); TimestampFormat format = TimestampFormatProvider.get(); format.markup(text, timestamp); text.addMarkup(0, 26, "<span style=\"display: none\">", "</span>"); } catch (DateTimeParseException x) { } } } return this; }
Source:
<code>public Map createVolume(String sdUUID, String spUUID, String imgUUID, String size, Integer volFormat, Integer preallocate, Integer diskType, String volUUID, String desc, String srcImgUUID, String srcVolUUID) { try { DataCenter dataCenter = getDataCenterById(spUUID); StorageDomain storageDomain = dataCenter.getStorageDomainMap().get(sdUUID); final Volume volume = new Volume(); volume.setId(volUUID); volume.setSize(size); volume.setVolFormat(volFormat); volume.setPreallocate(preallocate); volume.setDiskType(diskType); volume.setImgUUID(imgUUID); volume.setDesc(desc); volume.setSrcImgUUID(srcImgUUID); volume.setSrcVolUUID(srcVolUUID); log.info("Adding volume: for sp: {}, sd: {}", new Object[] { volUUID, spUUID, sdUUID }); storageDomain.getVolumes().put(volUUID, volume); updateDataCenter(dataCenter); final Map resultMap = getOKStatus(); final Task task = new Task(getUuid()); resultMap.put("uuid", task.getId()); <START> syncTask((Host) <END> VdsmManager.getInstance().getSpmHost(spUUID), task); TaskProcessor.getInstance().addTask(new TaskRequest(TaskType.FINISH_CREATE_VOLUME, 3000l, task)); return resultMap; } catch (Exception e) { throw error(e); } }</code><technical_language>typing is fixed do need this casting</technical_language>

Target:
public Map createVolume(String sdUUID, String spUUID, String imgUUID, String size, Integer volFormat, Integer preallocate, Integer diskType, String volUUID, String desc, String srcImgUUID, String srcVolUUID) { try { DataCenter dataCenter = getDataCenterById(spUUID); StorageDomain storageDomain = dataCenter.getStorageDomainMap().get(sdUUID); final Volume volume = new Volume(); volume.setId(volUUID); volume.setSize(size); volume.setVolFormat(volFormat); volume.setPreallocate(preallocate); volume.setDiskType(diskType); volume.setImgUUID(imgUUID); volume.setDesc(desc); volume.setSrcImgUUID(srcImgUUID); volume.setSrcVolUUID(srcVolUUID); log.info("Adding volume: for sp: {}, sd: {}", new Object[] { volUUID, spUUID, sdUUID }); storageDomain.getVolumes().put(volUUID, volume); updateDataCenter(dataCenter); final Map resultMap = getOKStatus(); final Task task = new Task(getUuid()); resultMap.put("uuid", task.getId()); syncTask(VdsmManager.getInstance().getSpmHost(spUUID), task); TaskProcessor.getInstance().addTask(new TaskRequest(TaskType.FINISH_CREATE_VOLUME, 3000l, task)); return resultMap; } catch (Exception e) { throw error(e); } }
Source:
<code>public Serializable execute(TaskResult... results) throws IOException, ExecutionException, InterruptedException { List<String> filesRelativePathName = new ArrayList<>(); File file = new File(inputPath); containerURL = AzureStorageConnectorUtils.createContainerURL(accountName, accountKey, containerName); if (file.exists()) { if (file.isDirectory()) { if (optionalBlobName.isPresent()) { filesRelativePathName = recursiveFolderUpload(inputPath, optionalBlobName.get(), true); } else { filesRelativePathName = recursiveFolderUpload(inputPath, "", false); } } else { if (optionalBlobName.isPresent()) { uploadFile(file, optionalBlobName.get()); } else { uploadFile(file, file.getName()); <START> } <END> filesRelativePathName.add(file.getPath()); } } else { throw new FileNotFoundException("The input file cannot be found at " + inputPath); } return (Serializable) filesRelativePathName; }</code><technical_language>replace java if (optionalBlobName.isPresent()) { uploadFile(file, optionalBlobName.get()); } else { uploadFile(file, file.getName()); } java uploadFile(file, optionalBlobName.orElse(file.getName());</technical_language>

Target:
public Serializable execute(TaskResult... results) throws IOException, ExecutionException, InterruptedException { List<String> filesRelativePathName = new ArrayList<>(); File file = new File(inputPath); containerURL = AzureStorageConnectorUtils.createContainerURL(storageAccount, accountKey, containerName); if (file.exists()) { if (file.isDirectory()) { if (optionalBlobName.isPresent()) { filesRelativePathName = recursiveFolderUpload(inputPath, optionalBlobName.get(), true); } else { filesRelativePathName = recursiveFolderUpload(inputPath, "", false); } } else { uploadFile(file, optionalBlobName.orElse(file.getName())); filesRelativePathName.add(file.getPath()); } } else { throw new FileNotFoundException("The input file cannot be found at " + inputPath); } return (Serializable) filesRelativePathName; }
Source:
<code>public void refreshDataCenterInfoIfRequired() { String existingAddress = instanceInfo.getHostName(); String newAddress; if (config instanceof RefreshableInstanceConfig) { newAddress = ((RefreshableInstanceConfig) config).resolveDefaultAddress(true); } else { newAddress = config.getHostName(true); } String newIp = config.getIpAddress(); if (newAddress != null && !newAddress.equals(existingAddress)) { logger.warn("The address changed from : => {}", existingAddress, newAddress); InstanceInfo.Builder builder = new InstanceInfo.Builder(instanceInfo); builder.setHostName(newAddress).setIPAddr(newIp).setDataCenterInfo(config.getDataCenterInfo()); instanceInfo.setIsDirty(); } String existingSpotInstanceAction = instanceInfo.getMetadata().get(AmazonInfo.MetaDataKey.spotInstanceAction.name); DataCenterInfo dataCenterInfo = config.getDataCenterInfo(); if (dataCenterInfo instanceof AmazonInfo) { AmazonInfo amazonInfo = (AmazonInfo) dataCenterInfo; <START> String newSpotInstanceAction = amazonInfo.getMetadata().get(AmazonInfo.MetaDataKey.spotInstanceAction.name); <END> if (newSpotInstanceAction != null && !newSpotInstanceAction.equals(existingSpotInstanceAction)) { logger.warn(String.format("The spot instance termination action changed from: %s => %s", existingSpotInstanceAction, newSpotInstanceAction)); InstanceInfo.Builder builder = new InstanceInfo.Builder(instanceInfo); builder.setDataCenterInfo(config.getDataCenterInfo()); instanceInfo.setIsDirty(); } } }</code><technical_language>is unfortunate API for AmazonInfo is a bit leaky, preferred API extract data is <LINK_0>, enum directly</technical_language>

Target:
public void refreshDataCenterInfoIfRequired() { String existingAddress = instanceInfo.getHostName(); String existingSpotInstanceAction = null; if (instanceInfo.getDataCenterInfo() instanceof AmazonInfo) { existingSpotInstanceAction = ((AmazonInfo) instanceInfo.getDataCenterInfo()).get(AmazonInfo.MetaDataKey.spotInstanceAction); } String newAddress; if (config instanceof RefreshableInstanceConfig) { newAddress = ((RefreshableInstanceConfig) config).resolveDefaultAddress(true); } else { newAddress = config.getHostName(true); } String newIp = config.getIpAddress(); if (newAddress != null && !newAddress.equals(existingAddress)) { logger.warn("The address changed from : => {}", existingAddress, newAddress); updateInstanceInfo(newAddress, newIp); } if (config.getDataCenterInfo() instanceof AmazonInfo) { String newSpotInstanceAction = ((AmazonInfo) config.getDataCenterInfo()).get(AmazonInfo.MetaDataKey.spotInstanceAction); if (newSpotInstanceAction != null && !newSpotInstanceAction.equals(existingSpotInstanceAction)) { logger.info(String.format("The spot instance termination action changed from: %s => %s", existingSpotInstanceAction, newSpotInstanceAction)); updateInstanceInfo(null , null ); } } }
Source:
<code>public void init() throws IOException { resultPath = tempFolder().newFolder().toURI().toString(); <START> clear(); <END> env().setParallelism(3); env().enableCheckpointing(100); rows = new ArrayList<>(); for (int i = 0; i < 100; i++) { rows.add(Row.of(i, String.valueOf(i % 10), String.valueOf(i))); } DataStream<Row> stream = new DataStream<>(env().getJavaEnv().addSource( new ParallelFiniteTestSource<>(rows), new RowTypeInfo( new TypeInformation[] {Types.INT, Types.STRING, Types.STRING}, new String[] {"a", "b", "c"}))); tEnv().createTemporaryView("my_table", stream); }</code><technical_language>do need call clear here</technical_language>

Target:
public void init() throws IOException { resultPath = tempFolder().newFolder().toURI().toString(); env().setParallelism(3); env().enableCheckpointing(100); List<Row> rows = new ArrayList<>(); for (int i = 0; i < 100; i++) { rows.add(Row.of(i, String.valueOf(i % 10), String.valueOf(i))); } this.expectedRows = new ArrayList<>(); this.expectedRows.addAll(rows); this.expectedRows.addAll(rows); this.expectedRows.sort(Comparator.comparingInt(o -> (Integer) o.getField(0))); DataStream<Row> stream = new DataStream<>(env().getJavaEnv().addSource( new ParallelFiniteTestSource<>(rows), new RowTypeInfo( new TypeInformation[] {Types.INT, Types.STRING, Types.STRING}, new String[] {"a", "b", "c"}))); tEnv().createTemporaryView("my_table", stream); }
Source:
<code>public void testGetProjcetMembers3() throws Exception { CreateAccount CA = new CreateAccount(1); CA.exe(); AddUserToRole addUserToRole = new AddUserToRole(mCP, CA); addUserToRole.exe_PO(); <START> AccountHelper ah = new AccountHelper(mConfig.getUserSession()); <END> ah.removeAssignRole(CA.getAccountList().get(0).getId(), mCP.getAllProjects().get(0).getId(), ScrumEnum.SCRUMROLE_PRODUCTOWNER); addUserToRole.exe_SM(); String projectName = this.mIProject.getName(); request.setHeader("Referer", "?PID=" + projectName); addRequestParameter("_dc", String.valueOf(System.currentTimeMillis())); request.getSession().setAttribute("UserSession", mConfig.getUserSession()); actionPerform(); verifyNoActionErrors(); verifyNoActionMessages(); String actualResponseText = response.getWriterBuffer().toString(); assertEquals(getExpectedProjectMember(CA.getAccountList().get(0)), actualResponseText); }</code><technical_language>naming</technical_language>

Target:
public void testGetProjcetMembers3() throws Exception { CreateAccount CA = new CreateAccount(1); CA.exe(); AddUserToRole AUTR = new AddUserToRole(mCP, CA); AUTR.exe_PO(); AccountHelper accountHelper = new AccountHelper(mConfig.getUserSession()); accountHelper.removeAssignRole(CA.getAccountList().get(0).getId(), mCP.getAllProjects().get(0).getId(), ScrumEnum.SCRUMROLE_PRODUCTOWNER); AUTR.exe_SM(); String projectName = this.mIProject.getName(); request.setHeader("Referer", "?PID=" + projectName); addRequestParameter("_dc", String.valueOf(System.currentTimeMillis())); request.getSession().setAttribute("UserSession", mConfig.getUserSession()); actionPerform(); verifyNoActionErrors(); verifyNoActionMessages(); String actualResponseText = response.getWriterBuffer().toString(); assertEquals(getExpectedProjectMember(CA.getAccountList().get(0)), actualResponseText); }
Source:
<code>public void setUp() { try { final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(TEST_TRACE.getFullPath()), null); final File test = new File(FileLocator.toFileURL(location).toURI()); fTrace = new TmfTraceStub(test.toURI().getPath(), ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, false, null); TmfSignalManager.deregister(fTrace); fTrace.indexTrace(true); } catch (final TmfTraceException e) { <START> e.printStackTrace(); <END> } catch (final URISyntaxException e) { e.printStackTrace(); } catch (final IOException e) { e.printStackTrace(); } }</code><technical_language>fail() instead</technical_language>

Target:
public void setUp() { try { final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(TEST_TRACE.getFullPath()), null); final File test = new File(FileLocator.toFileURL(location).toURI()); fTrace = new TmfTraceStub(test.toURI().getPath(), ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, false, null); TmfSignalManager.deregister(fTrace); fTrace.indexTrace(true); } catch (final TmfTraceException e) { fail("Exception setting up the trace: " + e.getMessage()); } catch (final URISyntaxException e) { fail("URI syntax exception: " + e.getMessage()); } catch (final IOException e) { fail("I/O exception while setting up the test: " + e.getMessage()); } }
Source:
<code>private void onTopologyChanged() { if (topologyListener == null) { <START> TracingService.logErrorInSpan(getContext().getCurrentSpan(), <END> "IllegalStateException: topologyListener should not be null when calling onTopologyChanged method"); throw new IllegalStateException( "topologyListener should not be null when calling onTopologyChanged method"); } reactOnTopologyChange(); }</code><technical_language>user need it, is internal exception, track in logs</technical_language>

Target:
private void onTopologyChanged() { if (topologyListener == null) { throw new IllegalStateException( "topologyListener should not be null when calling onTopologyChanged method"); } reactOnTopologyChange(); }
Source:
<code>ExportArguments(XWikiContext context) { XWikiRequest request = context.getRequest(); this.description = request.get("description"); this.name = request.get("name"); if (StringUtils.isBlank(name)) { this.name = context.getDoc().getFullName(); } String[] pagesParam = request.getParameterValues("pages"); String checkedPagesParam = request.get("checked-pages"); if (!StringUtils.isEmpty(checkedPagesParam)) { <START> this.checkedPages = checkedPagesParam.split("&"); <END> } else { this.checkedPages = pagesParam; } String otherPagesRequestValue = request.get("other-pages"); this.otherPages = Boolean.valueOf(otherPagesRequestValue); this.uncheckedPages = null; if (!StringUtils.isEmpty(request.get("unchecked-pages"))) { this.uncheckedPages = request.get("unchecked-pages").split(PAGE_SEPARATOR); } }</code><technical_language>code easier understand if decode done here. checkedPages a list of pages :)</technical_language>

Target:
ExportArguments(XWikiContext context) throws XWikiException { XWikiRequest request = context.getRequest(); this.description = request.get("description"); this.name = request.get("name"); if (StringUtils.isBlank(name)) { this.name = context.getDoc().getFullName(); } String[] pages = request.getParameterValues("pages"); String[] excludes = request.getParameterValues("excludes"); this.exportPages = new LinkedHashMap<>(); if (pages != null) { for (int i = 0; i < pages.length; i++) { List<String> excludedPages; if (excludes != null && i < excludes.length) { excludedPages = this.decodePages(excludes[i], context); } else { excludedPages = Collections.emptyList(); } this.exportPages.put(pages[i], excludedPages); } } }
Source:
<code>public Collection<Feature> getEnabledFeatures() { if (enabledFeatures == null && parent != null) return parent.getEnabledFeatures(); <START> return enabledFeatures; <END> }</code><technical_language>concern above</technical_language>

Target:
public Collection<Feature> getEnabledFeatures() { if(initialized) { return enabledFeatures; } Set<Feature> set = new HashSet<Feature>(); if (parent != null) set.addAll(parent.getEnabledFeatures()); set.addAll(enabledFeatures); return set; }
Source:
<code>boolean isAePrecaptureRequired(TakePictureState state) { <START> if (isCamera2LegacyDevice()) { <END> return false; } switch (getFlashMode()) { case FLASH_MODE_ON: return true; case FLASH_MODE_AUTO: return state.mPreCaptureState.getAeState() == AeState.FLASH_REQUIRED; case FLASH_MODE_OFF: return false; } throw new AssertionError(getFlashMode()); }</code><technical_language>move this a camera2 implementation, leaking camera2 implementation details here. a thought a ImagePrecapture interface default flash mode, in ImageCaptureProvider if device is legacy provide implementation return precapture is needed</technical_language>

Target:
boolean isAePrecaptureRequired(TakePictureState state) { switch (getFlashMode()) { case FLASH_MODE_ON: return true; case FLASH_MODE_AUTO: return state.mPreCaptureState.getAeState() == AeState.FLASH_REQUIRED; case FLASH_MODE_OFF: return false; } throw new AssertionError(getFlashMode()); }
Source:
<code>private List<Interval> parseInterval(List<String> intervalExpressions) { Preconditions.checkState(intervalExpressions != null && intervalExpressions.size() == 1, "Cannot parse range expressions from query: %s", intervalExpressions); long startTime = MIN_START_TIME; long endTime = MAX_END_TIME; String intervalExpression = intervalExpressions.get(0); <START> String[] s = intervalExpression.substring(1, intervalExpression.length() - 1).split("\\s+"); <END> if (!s[0].equals("*")) { startTime = _timeFormatSpec.fromFormatToMillis(s[0]); if (intervalExpression.startsWith("(")) { startTime++; } } if (!s[1].equals("*")) { endTime = _timeFormatSpec.fromFormatToMillis(s[1]); if (intervalExpression.endsWith(")")) { endTime--; } } if (startTime > endTime) { return Collections.emptyList(); } return Collections.singletonList(new Interval(startTime, endTime)); }</code><technical_language>(Critical) arbitrary whitespace delimiter (they valid value, I '\0 is a whitespace). refer RangePredicate.java parse range string</technical_language>

Target:
private List<Interval> parseInterval(List<String> intervalExpressions) { Preconditions.checkState(intervalExpressions != null && intervalExpressions.size() == 1, "Cannot parse range expressions from query: %s", intervalExpressions); long startTime = MIN_START_TIME; long endTime = MAX_END_TIME; String intervalExpression = intervalExpressions.get(0); boolean startInclusive = intervalExpression.charAt(0) == START_INCLUSIVE; boolean endInclusive = intervalExpression.charAt(intervalExpression.length() - 1) == END_INCLUSIVE; String interval = intervalExpression.substring(1, intervalExpression.length() - 1); String[] split = StringUtils.split(interval, DELIMITER); if (split.length != 2) { split = StringUtils.split(interval, LEGACY_DELIMITER); } if (!split[0].equals(UNBOUNDED)) { startTime = startInclusive? _timeFormatSpec.fromFormatToMillis(split[0]) + 1 : _timeFormatSpec.fromFormatToMillis(split[0]); } if (!split[1].equals(UNBOUNDED)) { endTime = endInclusive ? _timeFormatSpec.fromFormatToMillis(split[1]) - 1 : _timeFormatSpec.fromFormatToMillis(split[1]); } if (startTime > endTime) { return Collections.emptyList(); } return Collections.singletonList(new Interval(startTime, endTime)); }
Source:
<code>public static Optional<CompressionCodec> getCompressionCodec(TextInputFormat inputFormat, Path file) throws NoSuchFieldException, IllegalAccessException { <START> if (inputFormat == null || file == null) { <END> return Optional.empty(); } Field field = inputFormat.getClass().getDeclaredField("compressionCodecs"); if (field == null) { return Optional.empty(); } field.setAccessible(true); CompressionCodecFactory compressionCodecs = (CompressionCodecFactory) field.get(inputFormat); return Optional.ofNullable(compressionCodecs.getCodec(file)); }</code><technical_language>Remove checks, call method null. (As a general code style, write code lenient of nulls in Presto.)</technical_language>

Target:
public static Optional<CompressionCodec> getCompressionCodec(TextInputFormat inputFormat, Path file) { CompressionCodecFactory compressionCodecFactory; try { compressionCodecFactory = (CompressionCodecFactory) COMPRESSION_CODECS_FIELD.get(inputFormat); } catch (IllegalAccessException e) { throw new PrestoException(GENERIC_INTERNAL_ERROR, "Failed to find compressionCodec for inputFormat: " + inputFormat.getClass().getName(), e); } if (compressionCodecFactory == null) { return Optional.empty(); } return Optional.ofNullable(compressionCodecFactory.getCodec(file)); }