auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void moveDocument(Exchange exchange) throws Exception { validateRequiredHeader(exchange, CamelCMISConstants.CMIS_DESTIONATION_FOLDER_ID); validateRequiredHeader(exchange, CamelCMISConstants.CMIS_SOURCE_FOLDER_ID); validateRequiredHeader(exchange, CamelCMISConstants.CMIS_OBJECT_ID); Message message = exchange.getIn(); String destinationFolderId = message.getHeader(CamelCMISConstants.CMIS_DESTIONATION_FOLDER_ID, String.class); String sourceFolderId = message.getHeader(CamelCMISConstants.CMIS_SOURCE_FOLDER_ID, String.class); String objectId = message.getHeader(CamelCMISConstants.CMIS_OBJECT_ID, String.class); Folder sourceFolder = (Folder) getSessionFacade().getObjectById(sourceFolderId); Folder targetFolder = (Folder) getSessionFacade().getObjectById(destinationFolderId); Document document = (Document) getSessionFacade().getObjectById(objectId); if(document != null) { if(document.getAllowableActions().getAllowableActions().contains(Action.CAN_MOVE_OBJECT) == false) { <START> throw new CmisUnauthorizedException("Current user does not have permission to move " + objectId + document.getName()); <END> } try { document.move(sourceFolder, targetFolder); log.info("Moved document from " + sourceFolder.getName() + " to " + targetFolder.getName() ); } catch (CmisRuntimeException e) { log.error("Cannot move document to folder " + targetFolder.getName() + " : " + e.getMessage()); } } else { log.error("Document is null, cannot move!"); } }</code><technical_language>Usually, party exceptions in components. choose another example other components</technical_language>

Target:
public void moveDocument(Exchange exchange) throws Exception { validateRequiredHeader(exchange, CamelCMISConstants.CMIS_DESTIONATION_FOLDER_ID); validateRequiredHeader(exchange, CamelCMISConstants.CMIS_SOURCE_FOLDER_ID); validateRequiredHeader(exchange, CamelCMISConstants.CMIS_OBJECT_ID); Message message = exchange.getIn(); String destinationFolderId = message.getHeader(CamelCMISConstants.CMIS_DESTIONATION_FOLDER_ID, String.class); String sourceFolderId = message.getHeader(CamelCMISConstants.CMIS_SOURCE_FOLDER_ID, String.class); String objectId = message.getHeader(CamelCMISConstants.CMIS_OBJECT_ID, String.class); Folder sourceFolder = (Folder) getSessionFacade().getObjectById(sourceFolderId); Folder targetFolder = (Folder) getSessionFacade().getObjectById(destinationFolderId); Document document = (Document) getSessionFacade().getObjectById(objectId); if (document != null) { if (!document.getAllowableActions().getAllowableActions().contains(Action.CAN_MOVE_OBJECT)) { throw new CamelCmisUnauthorizedException("Current user does not have permission to move " + objectId + document.getName()); } try { document.move(sourceFolder, targetFolder); log.info("Moved document from " + sourceFolder.getName() + " to " + targetFolder.getName()); } catch (Exception e) { throw new CamelCmisException("Cannot move document to folder " + targetFolder.getName() + " : " + e.getMessage(), e); } } else { log.error("Document is null, cannot move!"); } }
Source:
<code>public static final byte[] readFully(final InputStream in, int sizeHint) throws IOException { <START> final ByteArrayOutputStream bos = new ByteArrayOutputStream(sizeHint); <END> final byte[] buf = new byte[2048]; for (;;) { final int read = in.read(buf, 0, buf.length); if (read == -1) { return bos.toByteArray(); } bos.write(buf, 0, read); } }</code><technical_language>I bet sizeHint is accurate. lets avoid copying. fall a copying behavior wrong: byte[] out = new byte[sizeHint]; int pos = 0; while (pos < out.length) { int read = in.read(out, pos, out.length - pos); if (read < 0) { byte[] res = new byte[pos]; System.arraycopy(out, 0, res, 0, pos); return res; } pos += read; } int = in.read(); if (last < 0) return out; TemporaryBuffer.Heap tmp = new TemporaryBuffer.Heap(Integer.MAX_VALUE); tmp.write(out); tmp.write(last); tmp.copy(in); return tmp.toByteArray();</technical_language>

Target:
public static final byte[] readFully(final InputStream in, int sizeHint) throws IOException { byte[] out = new byte[sizeHint]; int pos = 0; while (pos < out.length) { int read = in.read(out, pos, out.length - pos); if (read < 0) { byte[] res = new byte[pos]; System.arraycopy(out, 0, res, 0, pos); return res; } pos += read; } int last = in.read(); if (last < 0) return out; TemporaryBuffer.Heap tmp = new TemporaryBuffer.Heap(Integer.MAX_VALUE); tmp.write(out); tmp.write(last); tmp.copy(in); return tmp.toByteArray(); }
Source:
<code>List<MonitoringHandler> extractRuleSections( File file, String fileContent, Properties params ) { StringBuilder sb = new StringBuilder(); List<String> sections = new ArrayList<String>(); for( String s : Arrays.asList( fileContent.trim().split( "\n" ))) { s = s.trim(); if( s.length() == 0 || s.startsWith( COMMENT_DELIMITER )) continue; if( s.toLowerCase().startsWith( RULE_BEGINNING )) { <START> if(sb.length() > 0) sections.add( sb.toString()); <END> sb.setLength( 0 ); } sb.append( expandString(s, params) + "\n" ); } if(sb.length() > 0) sections.add( sb.toString()); List<MonitoringHandler> result = new ArrayList<MonitoringHandler> (); for( String s : sections ) { if( s.length() == 0 ) continue; Matcher m = this.eventPattern.matcher( s ); if( ! m.find()) continue; s = s.substring( m.end()).trim(); MonitoringHandler handler = createHandler( m.group( 1 ), m.group( 2 ), s ); if( handler != null ) result.add( handler ); else this.logger.warning( "No monitoring handler matched parser ID '" + m.group( 1 ) + "' in " + file + "." ); } return result; }</code><technical_language>Is this usefl check if sb.length() is positive? append "\n" below, so, if expandString returns "", add a new section anyway</technical_language>

Target:
List<MonitoringHandler> extractRuleSections( File file, String fileContent, Properties params ) { StringBuilder sb = new StringBuilder(); List<String> sections = new ArrayList<String>(); for( String s : Arrays.asList( fileContent.trim().split( "\n" ))) { s = s.trim(); if( s.length() == 0 || s.startsWith( COMMENT_DELIMITER )) continue; if( s.toLowerCase().startsWith( RULE_BEGINNING )) { addSectionIfNotEmpty(sections, sb.toString()); sb.setLength( 0 ); } sb.append( expandString(s, params) + "\n" ); } addSectionIfNotEmpty(sections, sb.toString()); List<MonitoringHandler> result = new ArrayList<MonitoringHandler> (); for( String s : sections ) { if( s.length() == 0 ) continue; Matcher m = this.eventPattern.matcher( s ); if( ! m.find()) continue; s = s.substring( m.end()).trim(); MonitoringHandler handler = createHandler( m.group( 1 ), m.group( 2 ), s ); if( handler != null ) result.add( handler ); else this.logger.warning( "No monitoring handler matched parser ID '" + m.group( 1 ) + "' in " + file + "." ); } return result; }
Source:
<code>public synchronized Realm getManagementRealm() { if (managementRealmConfig == null) { String managementUrl = getManagementRealmUrl(syncUser.getAuthenticationUrl()); managementRealmConfig = new SyncConfiguration.Builder(this, managementUrl) .modules(new PermissionModule()) .build(); } <START> return Realm.getInstance(managementRealmConfig); <END> }</code><technical_language>need put return Realm.getInstance(managementRealmConfig); of synchronized. a synchronized block move if (managementRealmConfig == null) {...} it</technical_language>

Target:
public Realm getManagementRealm() { synchronized (this) { if (managementRealmConfig == null) { String managementUrl = getManagementRealmUrl(syncUser.getAuthenticationUrl()); managementRealmConfig = new SyncConfiguration.Builder(this, managementUrl) .modules(new PermissionModule()) .build(); } } return Realm.getInstance(managementRealmConfig); }
Source:
<code>public ICPPEvaluation computeForFunctionCall(ActivationRecord record, ConstexprEvaluationContext context) { final ICPPEvaluation ownerEval = getOwnerEval(record); if (fMember instanceof ICPPMethod) { EvalBinding evalBinding = new EvalBinding(fMember, fType, getTemplateDefinition()); return evalBinding; } if(ownerEval == null) { return this; } int fieldPos = CPPASTFieldReference.getFieldPosition(fMember, fOwnerType); ICPPEvaluation evaluatedOwner = ownerEval.computeForFunctionCall(record, context); if (evaluatedOwner instanceof EvalPointer) { evaluatedOwner = ((EvalPointer) evaluatedOwner).dereference(); } if(fMember instanceof ICPPField) { ICPPField field = (ICPPField) fMember; if(field.getType() instanceof IArrayType) { EvalPointer evalPointer = new EvalPointer(record, new EvalCompositeAccess(new EvalCompositeAccess(evaluatedOwner, fieldPos), 0), <START> evaluatedOwner.getValue(null).get(fieldPos).getTemplateDefinition()); <END> return evalPointer; } } EvalReference evalRef = new EvalReference(record, new EvalCompositeAccess(evaluatedOwner, fieldPos), evaluatedOwner.getValue(null).get(fieldPos).getTemplateDefinition()); return evalRef; }</code><technical_language>this.getTemplateDefinition() here</technical_language>

Target:
public ICPPEvaluation computeForFunctionCall(ActivationRecord record, ConstexprEvaluationContext context) { final ICPPEvaluation ownerEval = getOwnerEval(record); if (fMember instanceof ICPPMethod) { EvalBinding evalBinding = new EvalBinding(fMember, fType, getTemplateDefinition()); return evalBinding; } if(ownerEval == null) { return this; } int fieldPos = CPPASTFieldReference.getFieldPosition(fMember, fOwnerType); ICPPEvaluation evaluatedOwner = ownerEval.computeForFunctionCall(record, context); if (evaluatedOwner instanceof EvalPointer) { evaluatedOwner = ((EvalPointer) evaluatedOwner).dereference(); } if(fMember instanceof ICPPField) { ICPPField field = (ICPPField) fMember; if(field.getType() instanceof IArrayType) { EvalPointer evalPointer = new EvalPointer(record, new EvalCompositeAccess(new EvalCompositeAccess(evaluatedOwner, fieldPos), 0), getTemplateDefinition()); return evalPointer; } } EvalReference evalRef = new EvalReference(record, new EvalCompositeAccess(evaluatedOwner, fieldPos), getTemplateDefinition()); return evalRef; }
Source:
<code>private Address(String address, String personal, boolean parse) { if (parse) { Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(address); if (tokens.length > 0) { Rfc822Token token = tokens[0]; mAddress = token.getAddress(); String name = token.getName(); if (!TextUtils.isEmpty(name)) { mPersonal = name; } else { mPersonal = (personal == null) ? null : personal.trim(); } } else { <START> Timber.e(new IllegalArgumentException(), "address " + address + " is invalid"); <END> } } else { mAddress = address; mPersonal = personal; } }</code><technical_language>want create exception object for logging. Also, Timber supports format strings. this be: java Timber.e("Invalid address: %s", address);</technical_language>

Target:
private Address(String address, String personal, boolean parse) { if (parse) { Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(address); if (tokens.length > 0) { Rfc822Token token = tokens[0]; mAddress = token.getAddress(); String name = token.getName(); if (!TextUtils.isEmpty(name)) { mPersonal = name; } else { mPersonal = (personal == null) ? null : personal.trim(); } } else { Timber.e("Invalid address: %s", address); } } else { mAddress = address; mPersonal = personal; } }
Source:
<code>public void addLegacyPasspointConfigWithCertCredential() throws Exception { String fqdn = "test.com"; String friendlyName = "Friendly Name"; long[] rcOIs = new long[] {0x1234L, 0x2345L}; String realm = "realm.com"; String caCertificateAlias = "CaCert"; String clientCertificateAlias = "ClientCert"; WifiConfiguration wifiConfig = new WifiConfiguration(); wifiConfig.FQDN = fqdn; wifiConfig.providerFriendlyName = friendlyName; wifiConfig.roamingConsortiumIds = rcOIs; wifiConfig.enterpriseConfig.setRealm(realm); wifiConfig.enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.TLS); wifiConfig.enterpriseConfig.setCaCertificateAlias(caCertificateAlias); wifiConfig.enterpriseConfig.setClientCertificateAlias(clientCertificateAlias); PasspointConfiguration passpointConfig = new PasspointConfiguration(); HomeSp homeSp = new HomeSp(); homeSp.setFqdn(fqdn); homeSp.setFriendlyName(friendlyName); homeSp.setRoamingConsortiumOis(rcOIs); passpointConfig.setHomeSp(homeSp); Credential credential = new Credential(); Credential.CertificateCredential certCredential = new Credential.CertificateCredential(); <START> certCredential.setCertType("x509v3"); <END> credential.setCertCredential(certCredential); credential.setRealm(realm); passpointConfig.setCredential(credential); assertTrue(PasspointManager.addLegacyPasspointConfig(wifiConfig)); verifyInstalledConfig(passpointConfig); }</code><technical_language>this one</technical_language>

Target:
public void addLegacyPasspointConfigWithCertCredential() throws Exception { String fqdn = "test.com"; String friendlyName = "Friendly Name"; long[] rcOIs = new long[] {0x1234L, 0x2345L}; String realm = "realm.com"; String caCertificateAlias = "CaCert"; String clientCertificateAlias = "ClientCert"; WifiConfiguration wifiConfig = new WifiConfiguration(); wifiConfig.FQDN = fqdn; wifiConfig.providerFriendlyName = friendlyName; wifiConfig.roamingConsortiumIds = rcOIs; wifiConfig.enterpriseConfig.setRealm(realm); wifiConfig.enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.TLS); wifiConfig.enterpriseConfig.setCaCertificateAlias(caCertificateAlias); wifiConfig.enterpriseConfig.setClientCertificateAlias(clientCertificateAlias); PasspointConfiguration passpointConfig = new PasspointConfiguration(); HomeSp homeSp = new HomeSp(); homeSp.setFqdn(fqdn); homeSp.setFriendlyName(friendlyName); homeSp.setRoamingConsortiumOis(rcOIs); passpointConfig.setHomeSp(homeSp); Credential credential = new Credential(); Credential.CertificateCredential certCredential = new Credential.CertificateCredential(); certCredential.setCertType(Credential.CertificateCredential.CERT_TYPE_X509V3); credential.setCertCredential(certCredential); credential.setRealm(realm); passpointConfig.setCredential(credential); assertTrue(PasspointManager.addLegacyPasspointConfig(wifiConfig)); verifyInstalledConfig(passpointConfig); }
Source:
<code>void setNewElementYPosition(final Element elementReference, final Element newElement) { <START> int referencePosition = getDndListComponent().getPositionY(elementReference); <END> getDndListComponent().setPositionY(newElement, referencePosition); }</code><technical_language>for consistency, final int</technical_language>

Target:
void setNewElementYPosition(final Element elementReference, final Element newElement) { final int referencePosition = getDndListComponent().getPositionY(elementReference); getDndListComponent().setPositionY(newElement, referencePosition); }
Source:
<code>protected void performOvfUpdate(StoragePool pool, Map<Guid, KeyValuePairCompat<String, List<Guid>>> vmsAndTemplateMetadata) { if (ovfOnAnyDomainSupported(pool)) { markDomainsWithOvfsForOvfUpdate(vmsAndTemplateMetadata.keySet()); <START> } else if (!getParameters().isUpdateOnlyDB()) { <END> getOvfUpdateProcessHelper().executeUpdateVmInSpmCommand(pool.getId(), vmsAndTemplateMetadata, Guid.Empty); } int i = 0; while (i < proccessedIdsInfo.size()) { int sizeToUpdate = Math.min(StorageConstants.OVF_MAX_ITEMS_PER_SQL_STATEMENT, proccessedIdsInfo.size() - i); List<Guid> guidsForUpdate = proccessedIdsInfo.subList(i, i + sizeToUpdate); List<Long> ovfGenerationsForUpdate = proccessedOvfGenerationsInfo.subList(i, i + sizeToUpdate); List<String> ovfConfigurationsInfo = proccessedOvfConfigurationsInfo.subList(i, i + sizeToUpdate); getVmAndTemplatesGenerationsDao().updateOvfGenerations(guidsForUpdate, ovfGenerationsForUpdate, ovfConfigurationsInfo); i += sizeToUpdate; initProcessedInfoLists(); } }</code><technical_language>please add a log update in db only</technical_language>

Target:
protected void performOvfUpdate(StoragePool pool, Map<Guid, KeyValuePairCompat<String, List<Guid>>> vmsAndTemplateMetadata) { if (ovfOnAnyDomainSupported(pool)) { markDomainsWithOvfsForOvfUpdate(vmsAndTemplateMetadata.keySet()); } else if (getParameters().isUpdateStorage()) { getOvfUpdateProcessHelper().executeUpdateVmInSpmCommand(pool.getId(), vmsAndTemplateMetadata, Guid.Empty); } else { log.info("No storage update was performed."); } int i = 0; while (i < proccessedIdsInfo.size()) { int sizeToUpdate = Math.min(StorageConstants.OVF_MAX_ITEMS_PER_SQL_STATEMENT, proccessedIdsInfo.size() - i); List<Guid> guidsForUpdate = proccessedIdsInfo.subList(i, i + sizeToUpdate); List<Long> ovfGenerationsForUpdate = proccessedOvfGenerationsInfo.subList(i, i + sizeToUpdate); List<String> ovfConfigurationsInfo = proccessedOvfConfigurationsInfo.subList(i, i + sizeToUpdate); getVmAndTemplatesGenerationsDao().updateOvfGenerations(guidsForUpdate, ovfGenerationsForUpdate, ovfConfigurationsInfo); i += sizeToUpdate; initProcessedInfoLists(); } }
Source:
<code>public Mono<ResponseEntity<?>> createWorkflowInstance( @RequestBody @ApiParam(value = "Submitted workflow instance information", required = true) CreateWorkflowInstanceRequest req) { return handleExceptions(() -> { <START> return wrapBlocking(() -> { <END> WorkflowInstance instance = createWorkflowConverter.convert(req); long id = workflowInstances.insertWorkflowInstance(instance); instance = workflowInstances.getWorkflowInstance(id, EnumSet.of(WorkflowInstanceInclude.CURRENT_STATE_VARIABLES), null); return created(URI.create(String.valueOf(id))).body(createWorkflowConverter.convert(instance)); }); }); }</code><technical_language>remove unnecessary { return x; } wrapBlocking</technical_language>

Target:
public Mono<ResponseEntity<?>> createWorkflowInstance( @RequestBody @ApiParam(value = "Submitted workflow instance information", required = true) CreateWorkflowInstanceRequest req) { return handleExceptions(() -> wrapBlocking(() -> { WorkflowInstance instance = createWorkflowConverter.convert(req); long id = workflowInstances.insertWorkflowInstance(instance); instance = workflowInstances.getWorkflowInstance(id, EnumSet.of(WorkflowInstanceInclude.CURRENT_STATE_VARIABLES), null); return created(URI.create(String.valueOf(id))).body(createWorkflowConverter.convert(instance)); })); }
Source:
<code>private void setupNullsFilter() { int count = topLevelOffsets[topLevelOffsetCount - 1]; nullsAllowed = ensureCapacity(nullsAllowed, count); nonNullsAllowed = ensureCapacity(nonNullsAllowed, count); for (int i = 0; i < count; i++) { long filter = elementFilters[i] & nullFilters; if (filter > 0) { <START> TupleDomainFilter tupleDomainFilter = tupleDomainFilters[Long.numberOfTrailingZeros(filter)]; <END> nullsAllowed[i] = tupleDomainFilter == IS_NULL; nonNullsAllowed[i] = tupleDomainFilter == IS_NOT_NULL; } else { nullsAllowed[i] = true; nonNullsAllowed[i] = true; } } nullsFilter.setup(nullsAllowed, nonNullsAllowed, topLevelOffsets); }</code><technical_language>Nit: static import numberOfTrailingZeros</technical_language>

Target:
private void setupNullsFilter() { int count = topLevelOffsets[topLevelOffsetCount - 1]; nullsAllowed = ensureCapacity(nullsAllowed, count); nonNullsAllowed = ensureCapacity(nonNullsAllowed, count); for (int i = 0; i < count; i++) { long filter = elementFilters[i] & nullFilters; if (filter > 0) { TupleDomainFilter tupleDomainFilter = tupleDomainFilters[numberOfTrailingZeros(filter)]; nullsAllowed[i] = tupleDomainFilter == IS_NULL; nonNullsAllowed[i] = tupleDomainFilter == IS_NOT_NULL; } else { nullsAllowed[i] = true; nonNullsAllowed[i] = true; } } nullsFilter.setup(nullsAllowed, nonNullsAllowed, topLevelOffsets); }
Source:
<code><START> public FlowControllingStreamObserver(StreamObserver<T> wrappedStreamObserver, AxonServerConfiguration configuration, <END> Function<FlowControl, T> requestWrapper, Predicate<T> isConfirmationMessage) { this.wrappedStreamObserver = wrappedStreamObserver; this.clientId = configuration.getClientId(); this.remainingPermits = new AtomicLong( configuration.getInitialNrOfPermits().longValue() - configuration.getNewPermitsThreshold().longValue() ); this.newPermits = configuration.getNrOfNewPermits(); this.initialNrofPermits=configuration.getInitialNrOfPermits(); this.newPermitsRequest = requestWrapper.apply(createRequest(newPermits)); this.isConfirmationMessage = isConfirmationMessage; this.requestWrapper = requestWrapper; }</code><technical_language>Nit: mind this constructor reference new created this(...)? This minimize potential discrepancies constructors</technical_language>

Target:
public FlowControllingStreamObserver(StreamObserver<T> wrappedStreamObserver, AxonServerConfiguration configuration, Function<FlowControl, T> requestWrapper, Predicate<T> isConfirmationMessage) { this(wrappedStreamObserver, configuration.getClientId(), configuration.getDefaultFlowControlConfiguration(), requestWrapper, isConfirmationMessage); }
Source:
<code><START> public synchronized boolean delete(String filename) { <END> if (filename.equals(MEMORY_BUFFER_NAME)) { mCurrentReportsSendBuffer = null; return true; } final File file = new File(mReportsDir, filename); boolean ok = true; if (Prefs.getInstance().isSaveStumbleLogs()) { File newFile = new File(sdcard_archive_path() + File.separator + filename); ok = copyAndDelete(file, newFile); if (!ok) { ok = file.delete(); } } else { ok = file.delete(); } mFileList.update(mReportsDir); return ok; }</code><technical_language>pull out this new logic a client-side subclass</technical_language>

Target:
public synchronized boolean delete(String filename) { if (filename.equals(MEMORY_BUFFER_NAME)) { mCurrentReportsSendBuffer = null; return true; } final File file = new File(mReportsDir, filename); boolean ok = file.delete(); mFileList.update(mReportsDir); return ok; }
Source:
<code>private IObservableValue<E> getDetailObservableValue(M masterKey) { IObservableValue<E> detailValue = detailObservableValueMap .get(masterKey); if (detailValue == null) { ObservableTracker.setIgnore(true); try { detailValue = observableValueFactory .createObservable(masterKey); <START> detailObservableValueMap.put(masterKey, detailValue); if (detailValue.isStale()) { addStaleDetailObservable(detailValue); } <END> } finally { ObservableTracker.setIgnore(false); } } return detailValue; }</code><technical_language>clear this code moved</technical_language>

Target:
private IObservableValue<E> getDetailObservableValue(M masterKey) { IObservableValue<E> detailValue = detailObservableValueMap.get(masterKey); if (detailValue == null) { ObservableTracker.setIgnore(true); try { detailValue = observableValueFactory.createObservable(masterKey); } finally { ObservableTracker.setIgnore(false); } detailObservableValueMap.put(masterKey, detailValue); if (detailValue.isStale()) { addStaleDetailObservable(detailValue); } } return detailValue; }
Source:
<code>public static CosmosAsyncClient getCosmosClient() { return new CosmosClientBuilder() .endpoint(SampleConfigurations.HOST) .key(SampleConfigurations.MASTER_KEY) .connectionPolicy(ConnectionPolicy.getDefaultPolicy()) .consistencyLevel(ConsistencyLevel.EVENTUAL) <START> .returnMinimalResponse(false) <END> .buildAsyncClient(); }</code><technical_language>ChangeFeedProcessor is a read-only, minimal response impacts it</technical_language>

Target:
public static CosmosAsyncClient getCosmosClient() { return new CosmosClientBuilder() .endpoint(SampleConfigurations.HOST) .key(SampleConfigurations.MASTER_KEY) .connectionPolicy(ConnectionPolicy.getDefaultPolicy()) .consistencyLevel(ConsistencyLevel.EVENTUAL) .contentResponseOnWriteEnabled(true) .buildAsyncClient(); }
Source:
<code><START> public static boolean didPressNextKey(int actionId, KeyEvent event) { <END> return actionId == EditorInfo.IME_ACTION_NEXT || event != null && (event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_NAVIGATE_NEXT); }</code><technical_language>I is a place for 2 methods. If I for this functionality. I AbstractFragment. I a suggestion though, thinking out loud, I guess. Edit: I noticed 2 methods static in AbstractFragment, I guess a good reason moving elsewhere</technical_language>

Target:
protected boolean didPressNextKey(int actionId, KeyEvent event) { return actionId == EditorInfo.IME_ACTION_NEXT || event != null && (event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_NAVIGATE_NEXT); }
Source:
<code>public <T extends RealType<T>> IterableInterval<T> equation( final IterableInterval<T> out, final UnaryFunctionOp<long[], Double> in) { @SuppressWarnings("unchecked") final IterableInterval<T> result = (IterableInterval<T>) ops().run( <START> net.imagej.ops.image.equation.DefaultCoordinatesEquation.class, out, in); <END> return result; }</code><technical_language>This ops().run(net.imagej.ops.Ops.Image.Equation.class, out, in). if writes another specialized CoordinatesEquation op, matched</technical_language>

Target:
public <T extends RealType<T>> IterableInterval<T> equation( final IterableInterval<T> out, final UnaryFunctionOp<long[], Double> in) { @SuppressWarnings("unchecked") final IterableInterval<T> result = (IterableInterval<T>) ops().run( net.imagej.ops.Ops.Image.Equation.class, out, in); return result; }
Source:
<code>public void updateDecoration(IStatus status) { String statusMessage = ""; if (status.isOK()) { PlanStatuses planStatuses = getPlanStatuses(); if (planStatuses.isSuccess()) { setTitleImage(CommonImages.getImageWithOverlay(BuildImages.VIEW_BUILDS, CommonImages.OVERLAY_SUCCESS, false, false)); } else if (planStatuses.isUnstable()) { setTitleImage(CommonImages.getImageWithOverlay(BuildImages.VIEW_BUILDS, CommonImages.OVERLAY_FAILED, false, false)); } else if (planStatuses.isFailed()) { setTitleImage(CommonImages.getImageWithOverlay(BuildImages.VIEW_BUILDS, CommonImages.OVERLAY_ERROR, false, false)); } else { setTitleImage(CommonImages.getImage(BuildImages.VIEW_BUILDS)); } <START> String message = NLS.bind("{0} Succeeded, {1} Unstable, {2} Failed", new Object[] { <END> planStatuses.numSuccess, planStatuses.numUnstable, planStatuses.numFailed }); setContentDescription(message); if (lastRefresh != null) { statusMessage = NLS.bind("Last update: {0}", DateFormat.getDateTimeInstance().format(lastRefresh)); } } else { setTitleImage(CommonImages.getImageWithOverlay(BuildImages.VIEW_BUILDS, CommonImages.OVERLAY_WARNING, false, false)); statusMessage = "Last update failed"; } if (statusMessage != null) { final IViewSite viewSite = getViewSite(); if (viewSite != null) { final IStatusLineManager statusLine = viewSite.getActionBars().getStatusLineManager(); if (statusLine != null) { statusLine.setMessage(statusMessage); } } } }</code><technical_language>message a bit odd if values 0. sense set null in case</technical_language>

Target:
public void updateDecoration(IStatus status) { String statusMessage = ""; if (status.isOK()) { BuildsSummary buildsSummary = getBuildsSummary(); if (buildsSummary.isSuccess()) { setTitleImage(CommonImages.getImageWithOverlay(BuildImages.VIEW_BUILDS, CommonImages.OVERLAY_SUCCESS, false, false)); } else if (buildsSummary.isUnstable()) { setTitleImage(CommonImages.getImageWithOverlay(BuildImages.VIEW_BUILDS, CommonImages.OVERLAY_FAILED, false, false)); } else if (buildsSummary.isFailed()) { setTitleImage(CommonImages.getImageWithOverlay(BuildImages.VIEW_BUILDS, CommonImages.OVERLAY_ERROR, false, false)); } else { setTitleImage(CommonImages.getImage(BuildImages.VIEW_BUILDS)); } if (!buildsSummary.isEmpty()) { setContentDescription(buildsSummary.toString()); } else { setContentDescription(""); } if (lastRefresh != null) { statusMessage = NLS.bind("Last update: {0}", DateFormat.getDateTimeInstance().format(lastRefresh)); } } else { setTitleImage(CommonImages.getImageWithOverlay(BuildImages.VIEW_BUILDS, CommonImages.OVERLAY_WARNING, false, false)); statusMessage = "Last update failed"; } if (statusMessage != null) { final IViewSite viewSite = getViewSite(); if (viewSite != null) { final IStatusLineManager statusLine = viewSite.getActionBars().getStatusLineManager(); if (statusLine != null) { statusLine.setMessage(statusMessage); } } } }
Source:
<code>public EObject getInput() { EObject input = null; if (inputRef == null || inputRef.get() == null) { if (getSession() != null && getSession().isOpen() && getURI().hasFragment()) { EObject eObject = getSession().getTransactionalEditingDomain().getResourceSet().getEObject(getURI(), false); if (eObject != null) { input = eObject; inputRef = new WeakReference<EObject>(eObject); } } } else { input = <START> inputRef.get(); <END> } return input; }</code><technical_language>session removed calls sessionRef.get()</technical_language>

Target:
public EObject getInput() { EObject input = inputRef != null ? inputRef.get() : null; if (input == null) { if (getSession() != null && getSession().isOpen() && getURI().hasFragment()) { input = getSession().getTransactionalEditingDomain().getResourceSet().getEObject(getURI(), false); if (input != null) { inputRef = new WeakReference<EObject>(input); } } } return input; }
Source:
<code>public SearchIndexBuilder makeSearchIndex() { SearchIndexBuilder sib = new SearchIndexBuilder().addAllAnnotations(this); sib.add(new CollectionSearchIndex<TopLevelItem>() { protected TopLevelItem get(String key) { return getItem(key); } protected Collection<TopLevelItem> all() { return getItems(); } @Override protected String getName(TopLevelItem o) { return o.getName(); } }); <START> addDisplayNamesToSearchIndex(sib, getItems(false)); <END> return sib; }</code><technical_language>is false here</technical_language>

Target:
public SearchIndexBuilder makeSearchIndex() { SearchIndexBuilder sib = new SearchIndexBuilder().addAllAnnotations(this); sib.add(new CollectionSearchIndex<TopLevelItem>() { protected TopLevelItem get(String key) { return getItem(key); } protected Collection<TopLevelItem> all() { return getItems(); } @Override protected String getName(TopLevelItem o) { return o.getName(); } }); addDisplayNamesToSearchIndex(sib, getItems(true)); return sib; }
Source:
<code>public void testOnTaskDetailsClosed() { <START> TaskSummary taskSummary = createTestTaskSummary(null, TASK_STATUS_EXITED, ""); <END> getPresenter().selectSummaryItem(taskSummary); assertEquals(taskSummary, getPresenter().getSelectedTask()); getPresenter().onTaskDetailsClosed(newCloseEventMock(PerspectiveIds.TASK_ADMIN_LIST_SCREEN)); assertEquals(taskSummary, getPresenter().getSelectedTask()); getPresenter().onTaskDetailsClosed(newCloseEventMock(PerspectiveIds.TASK_DETAILS_SCREEN)); assertNull(getPresenter().getSelectedTask()); }</code><technical_language>originally TASK_ID passed, null</technical_language>

Target:
public void testOnTaskDetailsClosed() { TaskSummary taskSummary = createTestTaskSummary(TASK_ID, TASK_STATUS_EXITED, ""); getPresenter().selectSummaryItem(taskSummary); assertEquals(taskSummary, getPresenter().getSelectedTask()); getPresenter().onTaskDetailsClosed(newCloseEventMock(PerspectiveIds.TASK_ADMIN_LIST_SCREEN)); assertEquals(taskSummary, getPresenter().getSelectedTask()); getPresenter().onTaskDetailsClosed(newCloseEventMock(PerspectiveIds.TASK_DETAILS_SCREEN)); assertNull(getPresenter().getSelectedTask()); }
Source:
<code>public Optional<InsightCard.Category> selectMarketingInsightToGenerate(final DateTime currentTime, final Set<InsightCard.Category> marketingSeenCategories, final Random random) { final Integer dayOfMonth = currentTime.getDayOfMonth(); LOGGER.debug("The day of the month is {}", dayOfMonth); switch (dayOfMonth) { case 1: case 4: case 7: case 10: case 13: case 16: case 19: final Set<InsightCard.Category> allowedCategories; <START> if (!marketingSeenCategories.isEmpty()) { <END> allowedCategories = getAllowedCategories(marketingInsightPool, marketingSeenCategories); } else { allowedCategories = marketingInsightPool; } final Optional<InsightCard.Category> pickedRandomInsight = pickRandomInsightCategory(allowedCategories, random); return pickedRandomInsight; } return Optional.absent(); }</code><technical_language>stuff this logic in "getAllowedCategories" if statement here. case statement return pickRandomInsightCategory(getAllowedCategories(marketingInsightPool, marketingSeenCategories),random);</technical_language>

Target:
public Optional<InsightCard.Category> selectMarketingInsightToGenerate(final DateTime currentTime, final Set<InsightCard.Category> marketingSeenCategories, final Random random) { final Integer dayOfMonth = currentTime.getDayOfMonth(); LOGGER.debug("The day of the month is {}", dayOfMonth); switch (dayOfMonth) { case 1: case 4: case 7: case 10: case 13: case 16: case 19: final Optional<InsightCard.Category> pickedRandomInsight = pickRandomInsightCategory(marketingInsightPool, marketingSeenCategories, random); return pickedRandomInsight; } return Optional.absent(); }
Source:
<code>public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) { Class<?> parameterType = parameterContext.getParameter().getType(); final boolean expectsPath = parameterType == Path.class; if (!expectsPath && parameterType != File.class) { throw new ParameterResolutionException("Can only resolve parameter of type " + Path.class.getName() + " or " + File.class.getName() + " but was: " + parameterType.getName()); } final Path path = extensionContext.getStore(NAMESPACE) .getOrComputeIfAbsent(KEY, key -> tempDirProvider.get(parameterContext, extensionContext, TEMP_DIR_PREFIX), CloseablePath.class) .get(); if (expectsPath) { return path; } try { return path.toFile(); } catch (final UnsupportedOperationException uoe) { <START> return new File(path.toAbsolutePath().toString()); <END> } }</code><technical_language>Please throw a ParameterResolutionException instead</technical_language>

Target:
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) { Class<?> parameterType = parameterContext.getParameter().getType(); boolean expectsPath = parameterType == Path.class; if (!expectsPath && parameterType != File.class) { throw new ParameterResolutionException("Can only resolve parameter of type " + Path.class.getName() + " or " + File.class.getName() + " but was: " + parameterType.getName()); } Path path = extensionContext.getStore(NAMESPACE) .getOrComputeIfAbsent(KEY, key -> tempDirProvider.get(parameterContext, extensionContext, TEMP_DIR_PREFIX), CloseablePath.class) .get(); if (expectsPath) { return path; } try { return path.toFile(); } catch (UnsupportedOperationException uoe) { throw new ParameterResolutionException("Unsupported FileSystem in tempDirProvider: " + tempDirProvider, uoe); } }
Source:
<code>private void addCnxn(NIOServerCnxn cnxn) throws IOException { InetAddress addr = cnxn.getSocketAddress(); if (addr == null) { <START> throw new IOException("Scoket of " + cnxn + " has been closed"); <END> } Set<NIOServerCnxn> set = ipMap.get(addr); if (set == null) { set = Collections.newSetFromMap( new ConcurrentHashMap<NIOServerCnxn, Boolean>(2)); Set<NIOServerCnxn> existingSet = ipMap.putIfAbsent(addr, set); if (existingSet != null) { set = existingSet; } } set.add(cnxn); cnxns.add(cnxn); touchCnxn(cnxn); }</code><technical_language>fix spelling</technical_language>

Target:
private void addCnxn(NIOServerCnxn cnxn) throws IOException { InetAddress addr = cnxn.getSocketAddress(); if (addr == null) { throw new IOException("Socket of " + cnxn + " has been closed"); } Set<NIOServerCnxn> set = ipMap.get(addr); if (set == null) { set = Collections.newSetFromMap( new ConcurrentHashMap<NIOServerCnxn, Boolean>(2)); Set<NIOServerCnxn> existingSet = ipMap.putIfAbsent(addr, set); if (existingSet != null) { set = existingSet; } } set.add(cnxn); cnxns.add(cnxn); touchCnxn(cnxn); }
Source:
<code>public synchronized void close() { <START> if (isOpen.getAndSet(false)) { <END> LOGGER.info("closing loading cache [%s]", id); loadingCache.close(); reverseLoadingCache.close(); } }</code><technical_language>General convention is check for fail case return, this like: java if (!isOpen.getAndSet(false)){ LOGGER.info("Closing closed lookup"); return } fall rest of method</technical_language>

Target:
public synchronized void close() { if (isOpen.getAndSet(false)) { LOGGER.info("Closing loading cache [%s]", id); loadingCache.close(); reverseLoadingCache.close(); } else { LOGGER.info("Closing already closed lookup"); return; } }
Source:
<code><START> public T newInstance(RowResult next, String[] fields) throws GoraException, IOException { <END> fields = getFieldsToQuery(fields); T persistent = newPersistent(); for (String f : fields) { Schema.Field field = fieldMap.get(f); Schema fieldSchema = field.schema(); Column column = kuduMapping.getFields().get(f); if (next.isNull(column.getName())) { continue; } Object fieldValue = KuduClientUtils.getObjectRow(next, column); Object v = deserializeFieldValue(field, fieldSchema, fieldValue, persistent); persistent.put(field.pos(), v); persistent.setDirty(field.pos()); } return persistent; }</code><technical_language>Remove declaration of thrown exception 'org.apache.gora.util.GoraException' is a subclass of 'java.io.IOException'</technical_language>

Target:
public T newInstance(RowResult next, String[] fields) throws IOException { fields = getFieldsToQuery(fields); T persistent = newPersistent(); for (String objField : fields) { Schema.Field field = fieldMap.get(objField); Schema fieldSchema = field.schema(); Column column = kuduMapping.getFields().get(objField); if (next.isNull(column.getName())) { continue; } Object fieldValue = KuduClientUtils.getObjectRow(next, column); Object obtainedValue = deserializeFieldValue(field, fieldSchema, fieldValue, persistent); persistent.put(field.pos(), obtainedValue); persistent.setDirty(field.pos()); } return persistent; }
Source:
<code>public static <M> StreamOperatorSpec<M, M> createMergeOperatorSpec(String opId) { <START> return StreamOperatorSpec.<M, M>createStreamOperatorSpec((M message) -> <END> new ArrayList<M>() { { this.add(message); } }, OperatorSpec.OpCode.MERGE, opId); }</code><technical_language>nice operator-specs created consistently - instead of statics for some constructors for others. Also, great do this a separate clean-up detract core-focus of this PR</technical_language>

Target:
public static <M> StreamOperatorSpec<M, M> createMergeOperatorSpec(String opId) { return new MergeOperatorSpec<>(opId); }
Source:
<code>public TestResult invoke(File ws, VirtualChannel channel) throws IOException { final long nowSlave = System.currentTimeMillis(); FileSet fs = Util.createFileSet(ws, testResults); DirectoryScanner ds = fs.getDirectoryScanner(); TestResult result = new TestResult(buildTime + (nowSlave - nowMaster), ds, keepLongStdio); String[] files = ds.getIncludedFiles(); if (files.length == 0) { <START> throw new AbortException(hudson.tasks.junit.Messages.JUnitResultArchiver_NoTestReportFound()); <END> } LOGGER.info("Found files: " + Arrays.toString(files)); return result; }</code><technical_language>Another case for Workflow sense for this fatal</technical_language>

Target:
public TestResult invoke(File ws, VirtualChannel channel) throws IOException { final long nowSlave = System.currentTimeMillis(); FileSet fs = Util.createFileSet(ws, testResults); DirectoryScanner ds = fs.getDirectoryScanner(); return new TestResult(buildTime + (nowSlave - nowMaster), ds, keepLongStdio); }
Source:
<code>public void testNormalizePath() { String uglyVolume = "hdfs://nn.somewhere.com:86753/accumulo/blah/../. String metadataEntry = uglyVolume + "/tables/" + id + "/" + dir + "/" + filename; <START> test(metadataEntry, "hdfs://nn.somewhere.com:86753/accumulo", id, dir, filename); <END> }</code><technical_language>nice verify TabletFile.equals TabletFile.hashCode work expected for normalized paths</technical_language>

Target:
public void testNormalizePath() { String uglyVolume = "hdfs://nn.somewhere.com:86753/accumulo/blah/../. String metadataEntry = uglyVolume + "/tables/" + id + "/" + dir + "/" + filename; TabletFile uglyFile = test(metadataEntry, "hdfs://nn.somewhere.com:86753/accumulo", id, dir, filename); TabletFile niceFile = new TabletFile( "hdfs://nn.somewhere.com:86753/accumulo/tables/" + id + "/" + dir + "/" + filename); assertEquals(niceFile, uglyFile); assertEquals(niceFile.hashCode(), uglyFile.hashCode()); }
Source:
<code>public long delayBeforeNextRetry(AmazonWebServiceRequest originalRequest, AmazonClientException exception, int retriesAttempted) { return (retriesAttempted > MAX_RETRIES) ? maxBackoffTime : <START> Math.min(((1L << retriesAttempted) * baseDelay), maxBackoffTime); <END> }</code><technical_language>Thanks for PR - good catch. I in terms of implementation potentially dodging problem - soon get MAX_RETRIES >= 63 issue (ie: Long's overflow) - adding another call Math us. This resolve issue: Math.max(1, 1 << retriesAttempted) pre-canned back-off strategies</technical_language>

Target:
public long delayBeforeNextRetry(AmazonWebServiceRequest originalRequest, AmazonClientException exception, int retriesAttempted) { return exponentialDelayHelper(retriesAttempted, baseDelay, maxBackoffTime); }
Source:
<code>protected void finishModelStage(final OperationContext context, final ModelNode operation, String attributeName, ModelNode newValue, ModelNode oldValue, final Resource model) throws OperationFailedException { super.finishModelStage(context, operation, attributeName, newValue, oldValue, model); assert !USE_JOURNAL_STORE.isAllowExpression() && !USE_JDBC_STORE.isAllowExpression() : "rework this before enabling expression"; if (attributeName.equals(USE_JOURNAL_STORE.getName()) || attributeName.equals(USE_JDBC_STORE.getName())) { if (newValue.isDefined() && newValue.asBoolean()) { final String mutualAttributeName = attributeName.equals(USE_JDBC_STORE.getName()) ? USE_JOURNAL_STORE.getName() : USE_JDBC_STORE.getName(); ModelNode resourceModel = model.getModel(); if (resourceModel.hasDefined(mutualAttributeName) && resourceModel.get(mutualAttributeName).asBoolean()) { resourceModel.get(mutualAttributeName).set(new ModelNode(false)); <START> context.addResponseWarning(Level.WARNING, "Please note that only journal store or jdbc store can be used, thus '" + mutualAttributeName + "' has been disabled."); <END> } } } context.addStep(JdbcStoreValidationStep.INSTANCE, OperationContext.Stage.MODEL); }</code><technical_language>Missing i18n</technical_language>

Target:
protected void finishModelStage(final OperationContext context, final ModelNode operation, String attributeName, ModelNode newValue, ModelNode oldValue, final Resource model) throws OperationFailedException { super.finishModelStage(context, operation, attributeName, newValue, oldValue, model); assert !USE_JOURNAL_STORE.isAllowExpression() && !USE_JDBC_STORE.isAllowExpression() : "rework this before enabling expression"; if (attributeName.equals(USE_JOURNAL_STORE.getName()) || attributeName.equals(USE_JDBC_STORE.getName())) { if (newValue.isDefined() && newValue.asBoolean()) { final String mutualAttributeName = attributeName.equals(USE_JDBC_STORE.getName()) ? USE_JOURNAL_STORE.getName() : USE_JDBC_STORE.getName(); ModelNode resourceModel = model.getModel(); if (resourceModel.hasDefined(mutualAttributeName) && resourceModel.get(mutualAttributeName).asBoolean()) { resourceModel.get(mutualAttributeName).set(new ModelNode(false)); } } } context.addStep(JdbcStoreValidationStep.INSTANCE, OperationContext.Stage.MODEL); }
Source:
<code>public void onWritePossible() throws IOException { while (out.isReady()) { try { buffer.clear(); if (in.read(buffer) < 0) { <START> try { in.close(); } catch (IOException e) { LOG.log(Level.SEVERE, e.getMessage(), e); } <END> buffer = null; } else { buffer.flip(); } } catch(Throwable t) { LOG.log(Level.SEVERE, t.getMessage(), t); buffer = null; } finally { if (buffer != null) { outChannel.write(buffer); } else { try { out.close(); } finally { context.complete(); } return; } } } }</code><technical_language>cleaning case is handled in buffer == null branch line 137 below. I expect add closing of input stream there, output stream is closed: try { in.close(); out.close(); } finally { [...]</technical_language>

Target:
public void onWritePossible() throws IOException { while (out.isReady()) { try { buffer.clear(); if (in.read(buffer) < 0) { buffer = null; } else { buffer.flip(); } } catch (Throwable t) { LOG.log(Level.SEVERE, t.getMessage(), t); buffer = null; } finally { if (buffer != null) { outChannel.write(buffer); } else { try { in.close(); } catch (IOException e) { LOG.log(Level.SEVERE, e.getMessage(), e); } try { out.close(); } finally { context.complete(); } return; } } } }
Source:
<code><START> public <T extends WithKey> String getKey(@Nonnull final T resource) { <END> return resource.getKey(); }</code><technical_language>yep figured out i need rectify configuration [here](<LINK_0> i opted for easier c7e02e7 run in osgi container</technical_language>

Target:
private <T extends WithKey> String getKey(@Nonnull final T resource) { return resource.getKey(); }
Source:
<code>private static FilePath locate(TopLevelItem item, String fullName, Node node, boolean create) { switch (MODE) { case DISABLED: return null; case MULTIBRANCH_ONLY: if (!(item.getParent() instanceof MultiBranchProject)) { return null; } break; case ENABLED: break; default: throw new AssertionError(); } FilePath workspace = getWorkspaceRoot(node); if (workspace == null) { return null; } if (fullName.contains("\n") || fullName.equals(INDEX_FILE_NAME)) { <START> throw new IllegalArgumentException(); END> } try { synchronized (node) { Map<String, String> index = load(workspace); String path = index.get(fullName); if (path != null) { return workspace.child(path); } if (PATH_MAX != 0 && item.getParent() instanceof MultiBranchProject) { path = minimize(fullName); FilePath dir = workspace.child(path); if (dir.isDirectory()) { index.put(fullName, path); save(index, workspace); return dir; } } FilePath dir = workspace.child(fullName); if (dir.isDirectory()) { index.put(fullName, fullName); save(index, workspace); return dir; } if (!create) { return null; } String mnemonic = mnemonicOf(fullName); for (int i = 1; ; i++) { path = StringUtils.right(i > 1 ? mnemonic + "_" + i : mnemonic, MAX_LENGTH); if (!index.containsKey(path)) { dir = workspace.child(path); if (!dir.isDirectory()) { index.put(fullName, path); save(index, workspace); return dir; } } } } } catch (IOException | InterruptedException x) { LOGGER.log(Level.WARNING, "could not manage workspaces on " + node, x); return null; } }</code><technical_language>add a message invalid name exception</technical_language>

Target:
private static FilePath locate(TopLevelItem item, String fullName, Node node, boolean create) { switch (MODE) { case DISABLED: return null; case MULTIBRANCH_ONLY: if (!(item.getParent() instanceof MultiBranchProject)) { return null; } break; case ENABLED: break; default: throw new AssertionError(); } FilePath workspace = getWorkspaceRoot(node); if (workspace == null) { return null; } if (fullName.contains("\n") || fullName.equals(INDEX_FILE_NAME)) { throw new IllegalArgumentException("Dangerous job name `" + fullName + "`"); } try { synchronized (node) { Map<String, String> index = load(workspace); String path = index.get(fullName); if (path != null) { return workspace.child(path); } if (PATH_MAX != 0 && item.getParent() instanceof MultiBranchProject) { path = minimize(fullName); FilePath dir = workspace.child(path); if (dir.isDirectory()) { index.put(fullName, path); save(index, workspace); return dir; } } FilePath dir = workspace.child(fullName); if (dir.isDirectory()) { index.put(fullName, fullName); save(index, workspace); return dir; } if (!create) { return null; } String mnemonic = mnemonicOf(fullName); for (int i = 1; ; i++) { path = StringUtils.right(i > 1 ? mnemonic + "_" + i : mnemonic, MAX_LENGTH); if (!index.containsKey(path)) { dir = workspace.child(path); if (!dir.isDirectory()) { index.put(fullName, path); save(index, workspace); return dir; } } } } } catch (IOException | InterruptedException x) { LOGGER.log(Level.WARNING, "could not manage workspaces on " + node, x); return null; } }