auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public <V> void execute(final Callback<V> callback) { checkNotNull("callback", callback); if (null != getSession().getSelectionControl()) { final AbstractCanvasHandler canvasHandler = getSession().getCanvasHandler(); final SelectionControl<AbstractCanvasHandler, Element> selectionControl = getSession().getSelectionControl(); final Collection<String> selectedItems = selectionControl.getSelectedItems(); if (selectedItems != null && !selectedItems.isEmpty()) { selectionControl.clearSelection(); <START> timerUtils.executeWithDelay(()-> { <END> final CommandResult<CanvasViolation> result = sessionCommandManager.execute(canvasHandler, canvasCommandFactory .delete(selectedItems.stream() .map(uuid -> canvasHandler.getGraphIndex().get(uuid)) .collect(Collectors.toList()))); if (!CommandUtils.isError(result)) { callback.onSuccess(); } else { callback.onError((V) new ClientRuntimeError("Error deleing elements [message=" + result.toString() + "]")); } }, 100); } else { callback.onError((V) new ClientRuntimeError("Cannot delete element, no element selected on canvas")); } } }</code><technical_language>delaying operation??</technical_language>

Target:
public <V> void execute(final Callback<V> callback) { checkNotNull("callback", callback); if (null != getSession().getSelectionControl()) { final AbstractCanvasHandler canvasHandler = getSession().getCanvasHandler(); final SelectionControl<AbstractCanvasHandler, Element> selectionControl = getSession().getSelectionControl(); final Collection<String> selectedItems = selectionControl.getSelectedItems(); clearSelectionEvent.fire(new CanvasClearSelectionEvent(canvasHandler)); if (selectedItems != null && !selectedItems.isEmpty()) { final CommandResult<CanvasViolation> result = sessionCommandManager.execute(canvasHandler, canvasCommandFactory.delete(selectedItems.stream() .map(uuid -> canvasHandler.getGraphIndex().get(uuid)) .filter(Objects::nonNull) .collect(Collectors.toList()))); if (!CommandUtils.isError(result)) { callback.onSuccess(); } else { callback.onError((V) new ClientRuntimeError("Error deleing elements [message=" + result.toString() + "]")); } } else { callback.onError((V) new ClientRuntimeError("Cannot delete element, no element selected on canvas")); } } }
Source:
<code>public String getFileAccessBlob(SecAccessType accesstype, String filename, String clustername, int expiryseconds, String jobid) throws Exception { DFUFileAccessResponse resp = getFileAccess(accesstype, filename, clustername, expiryseconds, jobid, false, false, false); if (resp != null) return resp.getMetaInfoBlob(); <START> return ""; <END> }</code><technical_language>@rpastrana Is resp == null case recoverable? returning empty "blob" sense? this exception return null</technical_language>

Target:
public String getFileAccessBlob(SecAccessType accesstype, String filename, String clustername, int expiryseconds, String jobid) throws Exception { DFUFileAccessResponse resp = getFileAccess(accesstype, filename, clustername, expiryseconds, jobid, false, false, false); if (resp == null) throw new Exception("Could not acquire file access for '" + filename + "' on cluster: '" + clustername + "'"); return resp.getMetaInfoBlob(); }
Source:
<code>public CommandCallback getCallback() { VDS <START> host = <END> getVds(); if (host.getClusterSupportsGlusterService() && getParameters().isStopGlusterService()) { return new HostMaintenanceCallback(); } else { return super.getCallback(); } }</code><technical_language>this inlined</technical_language>

Target:
public CommandCallback getCallback() { if (getVds().getClusterSupportsGlusterService() && getParameters().isStopGlusterService()) { return new HostMaintenanceCallback(); } else { return super.getCallback(); } }
Source:
<code><START> public void visitTryStatement(TryStatementTree tree) { <END> ExecutionState blockES = new ExecutionState(executionState); executionState = blockES; scan(tree.block()); for (CatchTree catchTree : tree.catches()) { executionState = new ExecutionState(blockES.parent); scan(catchTree.block()); blockES.merge(executionState); } if (tree.finallyBlock() != null) { executionState = new ExecutionState(blockES.parent); scan(tree.finallyBlock()); executionState = blockES.parent.overrideBy(blockES.overrideBy(executionState)); } else { executionState = blockES.parent.merge(blockES); } }</code><technical_language>ignoring resources</technical_language>

Target:
public void visitTryStatement(TryStatementTree tree) { ExecutionState blockES = new ExecutionState(executionState); executionState = blockES; scan(tree.block()); scan(tree.resources()); for (CatchTree catchTree : tree.catches()) { executionState = new ExecutionState(blockES.parent); scan(catchTree.block()); blockES.merge(executionState); } if (tree.finallyBlock() != null) { executionState = new ExecutionState(blockES.parent); scan(tree.finallyBlock()); executionState = blockES.parent.overrideBy(blockES.overrideBy(executionState)); } else { executionState = blockES.parent.merge(blockES); } }
Source:
<code>protected static synchronized ScheduledExecutorService executorService() { if (executorService == null) { <START> executorService = new ScheduledThreadPoolExecutor(10, new NamingThreadFactory(new DaemonThreadFactory(), "SCMEvent")); <END> } return executorService; }</code><technical_language>Note Timer is wrapped in utilities * impersonate ACL.SYSTEM * handle errors, if SafeTimerTask * maintain Thread.contextClassLoader of issues important for this usage, I idea offhand. Timer get a utility factory java public static ScheduledExecutorService newService(String name, int corePoolSize) { return new ImpersonatingScheduledExecutorService(new ErrorLoggingScheduledThreadPoolExecutor(corePoolSize, new NamingThreadFactory(new ClassLoaderSanityThreadFactory(new DaemonThreadFactory()), name)), ACL.SYSTEM); } for easy reuse</technical_language>

Target:
protected static synchronized ScheduledExecutorService executorService() { if (executorService == null) { executorService = new ImpersonatingScheduledExecutorService(new ScheduledThreadPoolExecutor(10, new NamingThreadFactory(new ClassLoaderSanityThreadFactory(new DaemonThreadFactory()), "SCMEvent")), ACL.SYSTEM); } return executorService; }
Source:
<code>private void adjustQuestionNumbersWithoutCommitting(int oldQuestionNumber, int newQuestionNumber, List<FeedbackQuestionAttributes> questions) { <START> if (oldQuestionNumber < 0 || newQuestionNumber < 0) { <END> Assumption.fail("Invalid question number"); } if (oldQuestionNumber > newQuestionNumber) { increaseQuestionNumber(newQuestionNumber, oldQuestionNumber, questions); } else if (oldQuestionNumber < newQuestionNumber) { decreaseQuestionNumber(oldQuestionNumber, newQuestionNumber, questions); } }</code><technical_language>Is 0 invalid question number well</technical_language>

Target:
private void adjustQuestionNumbersWithoutCommitting( int oldQuestionNumber, int newQuestionNumber, List<FeedbackQuestionAttributes> questions) { if (oldQuestionNumber <= 0 || newQuestionNumber <= 0) { Assumption.fail("Invalid question number"); } if (oldQuestionNumber > newQuestionNumber) { increaseQuestionNumber(newQuestionNumber, oldQuestionNumber, questions); } else if (oldQuestionNumber < newQuestionNumber) { decreaseQuestionNumber(oldQuestionNumber, newQuestionNumber, questions); } }
Source:
<code>private ScalarFunctionSplitter createScalarFunctionSplitter( int primitiveLeftFieldCount, ArrayBuffer<RexCall> extractedRexCalls, boolean isJavaTableFunction) { <START> if (isJavaTableFunction) { <END> return new ScalarFunctionSplitter( primitiveLeftFieldCount, extractedRexCalls, x -> PythonUtil.isPythonCall(x, null) ); } else { return new ScalarFunctionSplitter( primitiveLeftFieldCount, extractedRexCalls, PythonUtil::isNonPythonCall ); } }</code><technical_language>simplified as: return new ScalarFunctionSplitter( primitiveLeftFieldCount, extractedRexCalls, isJavaTableFunction ? x -> PythonUtil.isPythonCall(x, null) : PythonUtil::isNonPythonCall );</technical_language>

Target:
private ScalarFunctionSplitter createScalarFunctionSplitter( int primitiveLeftFieldCount, ArrayBuffer<RexCall> extractedRexCalls, boolean isJavaTableFunction) { return new ScalarFunctionSplitter( primitiveLeftFieldCount, extractedRexCalls, isJavaTableFunction ? x -> PythonUtil.isPythonCall(x, null) : PythonUtil::isNonPythonCall ); }
Source:
<code>private static Map<String, List<Integer>> fetchAllRelatedObjects(List<PerunBean> objects) { List<PerunBean> relatedObjects = new ArrayList<>(); Map<String, List<Integer>> mapOfBeans = new HashMap<>(); for (PerunBean object: objects) { relatedObjects.add(object); List<PerunBean> retrievedObjects = RelatedObjectsResolver.getValue(object.getBeanName()).apply(object); relatedObjects.addAll(retrievedObjects); } for (PerunBean object : relatedObjects) { if (!mapOfBeans.containsKey(object.getBeanName())) { List<Integer> listOfBeanIds = new ArrayList<>(); listOfBeanIds.add(object.getId()); mapOfBeans.put(object.getBeanName(), listOfBeanIds); } else if (!mapOfBeans.get(object.getBeanName()).contains(object.getId())) <START> mapOfBeans.get(object.getBeanName()).add(object.getId()); <END> } return mapOfBeans; }</code><technical_language>NIT: In this special case I of brackets in else if part</technical_language>

Target:
private static Map<String, Set<Integer>> fetchAllRelatedObjects(List<PerunBean> objects) { List<PerunBean> relatedObjects = new ArrayList<>(); Map<String, Set<Integer>> mapOfBeans = new HashMap<>(); for (PerunBean object: objects) { relatedObjects.add(object); List<PerunBean> retrievedObjects = RelatedObjectsResolver.getValue(object.getBeanName()).apply(object); relatedObjects.addAll(retrievedObjects); } for (PerunBean object : relatedObjects) { if (!mapOfBeans.containsKey(object.getBeanName())) mapOfBeans.put(object.getBeanName(), new HashSet<>()); mapOfBeans.get(object.getBeanName()).add(object.getId()); } return mapOfBeans; }
Source:
<code>public void putMonitoredFeed(String feedName){ MonitoredFeedsBean monitoredFeedsBean = new MonitoredFeedsBean(); monitoredFeedsBean.setFeedName(feedName); EntityManager entityManager = getEntityManager(); beginTransaction(entityManager); entityManager.persist(monitoredFeedsBean); <START> commitAndCloseTransaction(entityManager); <END> }</code><technical_language>commitAndCloseTransaction part of a finally statement</technical_language>

Target:
public void putMonitoredFeed(String feedName){ MonitoredFeedsBean monitoredFeedsBean = new MonitoredFeedsBean(); monitoredFeedsBean.setFeedName(feedName); EntityManager entityManager = getEntityManager(); try { beginTransaction(entityManager); entityManager.persist(monitoredFeedsBean); } finally { commitAndCloseTransaction(entityManager); } }
Source:
<code>public static void validateRecords(short version, MemoryRecords records) { if (version >= 3) { Iterator<MutableRecordBatch> iterator = records.batches().iterator(); if (!iterator.hasNext()) throw new InvalidRecordException("Produce requests with version " + version + " must have at least " + "one record batch"); MutableRecordBatch entry = iterator.next(); if (entry.magic() != RecordBatch.MAGIC_VALUE_V2) throw new InvalidRecordException("Produce requests with version " + version + " are only allowed to " + "contain record batches with magic version 2"); <START> if (version < 8 && entry.compressionType() == CompressionType.ZSTD) { <END> throw new UnsupportedCompressionTypeException("Produce requests with version " + version + " are not allowed to " + "use ZStandard compression"); } if (iterator.hasNext()) throw new InvalidRecordException("Produce requests with version " + version + " are only allowed to " + "contain exactly one record batch"); } }</code><technical_language>changing this? restriction ZSTD for v7</technical_language>

Target:
public static void validateRecords(short version, MemoryRecords records) { if (version >= 3) { Iterator<MutableRecordBatch> iterator = records.batches().iterator(); if (!iterator.hasNext()) throw new InvalidRecordException("Produce requests with version " + version + " must have at least " + "one record batch"); MutableRecordBatch entry = iterator.next(); if (entry.magic() != RecordBatch.MAGIC_VALUE_V2) throw new InvalidRecordException("Produce requests with version " + version + " are only allowed to " + "contain record batches with magic version 2"); if (version < 7 && entry.compressionType() == CompressionType.ZSTD) { throw new UnsupportedCompressionTypeException("Produce requests with version " + version + " are not allowed to " + "use ZStandard compression"); } if (iterator.hasNext()) throw new InvalidRecordException("Produce requests with version " + version + " are only allowed to " + "contain exactly one record batch"); } }
Source:
<code>public Multimap<String, String> createHttpHeadersForResource(final UriInfo uriInfo, final FedoraResource resource) { final Session internalSession = sessionFactory.getInternalSession(); final IdentifierConverter<Resource, FedoraResource> translator = new DefaultIdentifierTranslator(internalSession); final Model model = createDefaultModel(); final ListMultimap<String, String> headers = ArrayListMultimap.create(); LOGGER.debug("Adding WebAC Link Header for Resource: {}", resource); nodeService.find(internalSession, resource.getPath()).getTriples(translator, PropertiesRdfContext.class) .filter(t -> model.asStatement(t).getPredicate().hasURI(WEBAC_ACCESS_CONTROL_VALUE)) .filter(t -> t.getObject().isURI()) .forEachRemaining(t -> { <START> headers.put("Link", uriInfo.getBaseUriBuilder() <END> .path(translator.convert(model.asStatement(t).getObject().asResource()).getPath()) + "; rel=\"acl\""); }); return headers; }</code><technical_language>Instead of "hand creating" Link header, please javax.ws.rs.core.Link, in: <LINK_0></technical_language>

Target:
public Multimap<String, String> createHttpHeadersForResource(final UriInfo uriInfo, final FedoraResource resource) { final Session internalSession = sessionFactory.getInternalSession(); final IdentifierConverter<Resource, FedoraResource> translator = new DefaultIdentifierTranslator(internalSession); final Model model = createDefaultModel(); final ListMultimap<String, String> headers = ArrayListMultimap.create(); LOGGER.debug("Adding WebAC Link Header for Resource: {}", resource); nodeService.find(internalSession, resource.getPath()).getTriples(translator, PropertiesRdfContext.class) .filter(t -> model.asStatement(t).getPredicate().hasURI(WEBAC_ACCESS_CONTROL_VALUE)) .filter(t -> t.getObject().isURI()) .forEachRemaining(t -> { headers.put("Link", Link.fromUri(uriInfo.getBaseUriBuilder() .path(translator.convert(model.asStatement(t).getObject().asResource()).getPath()) .toString()).rel("acl").build().toString()); }); return headers; }
Source:
<code>private String joinJvmArgs() { StringBuilder allJvmArgs = new StringBuilder(""); for (String jvmArg : jvmArgs) { <START> String quote = isWindows() ? "\"" : ""; <END> allJvmArgs.append(" "); allJvmArgs.append(quote); allJvmArgs.append("--jvm_arg="); allJvmArgs.append(randomizePorts(jvmArg)); allJvmArgs.append(quote); } return allJvmArgs.toString(); }</code><technical_language>This moved for loop</technical_language>

Target:
private String joinJvmArgs() { StringBuilder allJvmArgs = new StringBuilder(""); String quote = isWindows() ? "\"" : ""; for (String jvmArg : jvmArgs) { allJvmArgs.append(" "); allJvmArgs.append(quote); allJvmArgs.append("--jvm_arg="); allJvmArgs.append(randomizePorts(jvmArg)); allJvmArgs.append(quote); } return allJvmArgs.toString(); }
Source:
<code>public void createCheckRunManyAnnotations() throws Exception { GHCheckRunBuilder.DraftOutput output = gitHub.getRepository("jglick/github-api-test") .createCheckRun("big", "4a929d464a2fae7ee899ce603250f7dab304bc4b") .withConclusion(GHCheckRun.Conclusion.SUCCESS) .withOutput("Big Run", "Lots of stuff here »"); for (int i = 0; i < 101; i++) { output.withAnnotation("stuff.txt", 1, GHCheckRun.AnnotationLevel.NOTICE, "hello #" + i).done(); } GHCheckRun checkRun = output.done().create(); assertEquals("completed", checkRun.getStatus()); <START> assertEquals("Big Run", checkRun.getOutput().getTitle()); <END> assertEquals(101, checkRun.getOutput().getAnnotationsCount()); assertEquals(537614832, checkRun.id); }</code><technical_language>Check OutputSummary well</technical_language>

Target:
public void createCheckRunManyAnnotations() throws Exception { GHCheckRunBuilder.Output output = new GHCheckRunBuilder.Output("Big Run", "Lots of stuff here »"); for (int i = 0; i < 101; i++) { output.add( new GHCheckRunBuilder.Annotation("stuff.txt", 1, GHCheckRun.AnnotationLevel.NOTICE, "hello #" + i)); } GHCheckRun checkRun = gitHub.getRepository("jglick/github-api-test") .createCheckRun("big", "4a929d464a2fae7ee899ce603250f7dab304bc4b") .withConclusion(GHCheckRun.Conclusion.SUCCESS) .add(output) .create(); assertEquals("completed", checkRun.getStatus()); assertEquals("Big Run", checkRun.getOutput().getTitle()); assertEquals("Lots of stuff here »", checkRun.getOutput().getSummary()); assertEquals(101, checkRun.getOutput().getAnnotationsCount()); assertEquals(546384622, checkRun.id); }
Source:
<code>public void testVMInsideInstall_MacOS() throws Exception { m = createMinimalConfiguration(TestEclipseDataArea.class.getName(), Constants.OS_MACOSX); <START> File jreLocation = new File(m.getLauncherData().getLauncher().getParentFile(), "../../../jre").getCanonicalFile(); <END> m.getLauncherData().setJvm(jreLocation); m.save(false); assertNotContent(getLauncherConfigFile(), jreLocation.getAbsolutePath()); assertContent(getLauncherConfigFile(), "jre"); assertContent(m.getLauncherData().getLauncherConfigLocation(), "-vm"); assertContent(m.getLauncherData().getLauncherConfigLocation(), "jre"); assertNotContent(m.getLauncherData().getLauncherConfigLocation(), "file:"); m.load(); assertEquals(jreLocation, m.getLauncherData().getJvm()); m.getLauncherData().setJvm(null); m.save(false); assertNotContent(m.getLauncherData().getLauncherConfigLocation(), "-vm"); assertNotContent(m.getLauncherData().getLauncherConfigLocation(), "jre"); }</code><technical_language>want resolve symlinks here</technical_language>

Target:
public void testVMInsideInstall_MacOS() throws Exception { m = createMinimalConfiguration(TestEclipseDataArea.class.getName(), Constants.OS_MACOSX); final String expectedRelativePath = "../../../jre"; File jreLocation = new File(m.getLauncherData().getLauncher().getParentFile(), expectedRelativePath); m.getLauncherData().setJvm(jreLocation); m.save(false); File launcherConfigFile = getLauncherConfigFile(); assertNotContent("No absolute JRE path must be present in " + launcherConfigFile, launcherConfigFile, jreLocation.getAbsolutePath()); assertContent("Relative JRE path must be present in " + launcherConfigFile, launcherConfigFile, expectedRelativePath); }
Source:
<code>public static void validateEmptyBucketToTempQueueMap(String senderId) { GatewaySender sender = getGatewaySender(senderId); int size = 0; <START> Set queues = ((AbstractGatewaySender) sender).getQueues(); <END> for (Object queue : queues) { PartitionedRegion region = (PartitionedRegion) ((ConcurrentParallelGatewaySenderQueue) queue).getRegion(); int buckets = region.getTotalNumberOfBuckets(); for (int bucket = 0; bucket < buckets; bucket++) { BlockingQueue newQueue = ((ConcurrentParallelGatewaySenderQueue) queue).getBucketTmpQueue((int) bucket); if (newQueue != null) { size += newQueue.size(); } } } final int finalSize = size; assertEquals("Expected elements in TempQueueMap: " + 0 + " but actual size: " + finalSize, 0, finalSize); }</code><technical_language>This Set<RegionQueue> avoid compiler warnings</technical_language>

Target:
public static void validateEmptyBucketToTempQueueMap(String senderId) { GatewaySender sender = getGatewaySender(senderId); int size = 0; Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues(); for (Object queue : queues) { PartitionedRegion region = (PartitionedRegion) ((ConcurrentParallelGatewaySenderQueue) queue).getRegion(); int buckets = region.getTotalNumberOfBuckets(); for (int bucket = 0; bucket < buckets; bucket++) { BlockingQueue<GatewaySenderEventImpl> newQueue = ((ConcurrentParallelGatewaySenderQueue) queue).getBucketTmpQueue(bucket); if (newQueue != null) { size += newQueue.size(); } } } final int finalSize = size; assertEquals("Expected elements in TempQueueMap: " + 0 + " but actual size: " + finalSize, 0, finalSize); }
Source:
<code>public static void addSerializableSupport(JDefinedClass jclass) { jclass._implements(Serializable.class); try { final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); final DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream); processDefinedClassForSerializableSupport(jclass, dataOutputStream); dataOutputStream.flush(); final MessageDigest digest = MessageDigest.getInstance("SHA"); final byte[] digestBytes = digest.digest(byteArrayOutputStream.toByteArray()); long serialVersionUID = 0L; for (int i = Math.min(digestBytes.length, 8) - 1; i >= 0; i--) { serialVersionUID = serialVersionUID << 8 | (long)(digestBytes[i] & 0xff); } JFieldVar serialUIDField = jclass.field(JMod.PRIVATE | JMod.STATIC | JMod.FINAL, long.class, "serialVersionUID"); serialUIDField.init(JExpr.lit(serialVersionUID)); } catch (IOException exception) { <START> final InternalError internalError = new InternalError(exception.getMessage()); <END> internalError.initCause(exception); throw internalError; } catch (NoSuchAlgorithmException exception) { final RuntimeException securityException = new SecurityException(exception.getMessage()); securityException.initCause(exception); throw securityException; } }</code><technical_language>use: java } catch (IOException e) { throw new GenerationException("Some explanatory message", e); } here</technical_language>

Target:
public static void addSerializableSupport(JDefinedClass jclass) { jclass._implements(Serializable.class); try { final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); final DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream); processDefinedClassForSerializableSupport(jclass, dataOutputStream); dataOutputStream.flush(); final MessageDigest digest = MessageDigest.getInstance("SHA"); final byte[] digestBytes = digest.digest(byteArrayOutputStream.toByteArray()); long serialVersionUID = 0L; for (int i = Math.min(digestBytes.length, 8) - 1; i >= 0; i--) { serialVersionUID = serialVersionUID << 8 | (long)(digestBytes[i] & 0xff); } JFieldVar serialUIDField = jclass.field(JMod.PRIVATE | JMod.STATIC | JMod.FINAL, long.class, "serialVersionUID"); serialUIDField.init(JExpr.lit(serialVersionUID)); } catch (IOException exception) { throw new GenerationException("IOException while generating serialversionUID field while adding serializable support to class: " + jclass.fullName(), exception); } catch (NoSuchAlgorithmException exception) { throw new GenerationException("SHA algorithm not found when trying to generate serialversionUID field while adding serializable support to class: " + jclass.fullName(), exception); } }
Source:
<code>public RepositoryFile createFile( final Serializable parentFolderId, final RepositoryFile file, final IRepositoryFileData data, final String versionMessage ) { Constructor exceptionConstructor = null; try { exceptionConstructor = UnifiedRepositoryCreateFileException.class.getConstructor( String.class, Throwable.class ); } catch ( NoSuchMethodException e ) { <START> e.printStackTrace(); <END> } return callLogThrow( new Callable<RepositoryFile>() { public RepositoryFile call() throws Exception { return delegatee.createFile( parentFolderId, file, data, versionMessage ); } }, Messages.getInstance().getString( "ExceptionLoggingDecorator.createFile", file.getName() ), exceptionConstructor ); }</code><technical_language>Pretty printStackTrace() in exception handlers. Especially swallowing exception point. If do get exception, end NPE below. Please fix this</technical_language>

Target:
public RepositoryFile createFile( final Serializable parentFolderId, final RepositoryFile file, final IRepositoryFileData data, final String versionMessage ) { Constructor exceptionConstructor = null; try { exceptionConstructor = UnifiedRepositoryCreateFileException.class.getConstructor( String.class, Throwable.class ); } catch ( NoSuchMethodException e ) { logger.error( e ); } return callLogThrow( new Callable<RepositoryFile>() { public RepositoryFile call() throws Exception { return delegatee.createFile( parentFolderId, file, data, versionMessage ); } }, Messages.getInstance().getString( "ExceptionLoggingDecorator.createFile", file.getName() ), exceptionConstructor ); }
Source:
<code>public static OrderLinePriceUpdateRequestBuilder prepare(final org.compiere.model.I_C_OrderLine orderLine) { return builder() <START> .updatePriceEnteredAndDiscountOnlyIfNotAlreadySet(true) <END> .updateLineNetAmt(true) .orderLine(InterfaceWrapperHelper.create(orderLine, I_C_OrderLine.class)) .resultUOM(ResultUOM.PRICE_UOM_IF_ORDERLINE_IS_NEW); }</code><technical_language>here..because e.g. if i untick manual-price checkbox, i want price reset pricing-engine.</technical_language>

Target:
public static OrderLinePriceUpdateRequestBuilder prepare(final org.compiere.model.I_C_OrderLine orderLine) { return builder() .updateLineNetAmt(true) .orderLine(InterfaceWrapperHelper.create(orderLine, I_C_OrderLine.class)) .resultUOM(ResultUOM.PRICE_UOM_IF_ORDERLINE_IS_NEW); }
Source:
<code>public byte getAbsSendTimeExtensionID(){ <START> return extensionID == -1 ? extensionID_for_debugging : extensionID ; <END> }</code><technical_language>please remove extensionID_for_debugging? testing jitsi-meet abs-send-time is configured id=3, test it</technical_language>

Target:
public byte getAbsSendTimeExtensionID(){ return extensionID; }
Source:
<code>public void put(K key, T obj) throws GoraException { try { if (obj.isDirty()) { Column pkc = kuduMapping.getPrimaryKey().get(0); Upsert upsert = table.newUpsert(); PartialRow row = upsert.getRow(); KuduClientUtils.addObjectRow(row, pkc, key); Schema schema = obj.getSchema(); List<Schema.Field> fields = schema.getFields(); for (Schema.Field field : fields) { Column mappedColumn = kuduMapping.getFields().get(field.name()); Object fieldValue = obj.get(field.pos()); if (mappedColumn != null && fieldValue != null) { Schema fieldSchema = field.schema(); Object serializedObj = serializeFieldValue(fieldSchema, fieldValue); KuduClientUtils.addObjectRow(row, mappedColumn, serializedObj); } else { <START> row.setNull(mappedColumn.getName()); <END> } } session.apply(upsert); } else { LOG.info("Ignored putting object in the store as it is neither " + "new, neither dirty.", new Object[]{obj}); } } catch (Exception e) { throw new GoraException(e); } }</code><technical_language>mappedColumn.getName() throw a null pointer exception</technical_language>

Target:
public void put(K key, T obj) throws GoraException { try { if (obj.isDirty()) { Column pkc = kuduMapping.getPrimaryKey().get(0); Upsert upsert = table.newUpsert(); PartialRow row = upsert.getRow(); KuduClientUtils.addObjectRow(row, pkc, key); Schema schemaObj = obj.getSchema(); List<Schema.Field> fields = schemaObj.getFields(); for (Schema.Field field : fields) { Column mappedColumn = kuduMapping.getFields().get(field.name()); if (mappedColumn != null) { Object fieldValue = obj.get(field.pos()); if (fieldValue != null) { Schema fieldSchema = field.schema(); Object serializedObj = serializeFieldValue(fieldSchema, fieldValue); KuduClientUtils.addObjectRow(row, mappedColumn, serializedObj); } else { row.setNull(mappedColumn.getName()); } } else { throw new GoraException("Unmapped field : " + field.name()); } } session.apply(upsert); } else { LOG.info("Ignored putting object in the store as it is neither " + "new, neither dirty.", new Object[]{obj}); } } catch (Exception e) { throw new GoraException(e); } }
Source:
<code>private static void createClause(Map<String, String> map) { boolean isEnd = true; <START> for (String key : map.keySet()) { <END> if (isEnd) { whereClause += "\"%" + key + "%\""; isEnd = false; } else { whereClause += " OR DeviceName LIKE"; whereClause += "\"%" + key + "%\""; } } }</code><technical_language>reason avoiding a StringBuilder here? classic case for += Strings. Do a new Stringbuilder(DRIVER_QUERY_BASE) append " (foo)" (1st iteration) " (foo)" (2nd+ iteration) loop</technical_language>

Target:
private static void createClause(Map<String, String> map) { driverQueryClause = "Win32_PnPSignedDriver WHERE DeviceName LIKE "; boolean isEnd = true; for (String key : map.keySet()) { if (isEnd) { driverQueryClause += "\"%" + key + "%\""; isEnd = false; } else { driverQueryClause += " OR DeviceName LIKE"; driverQueryClause += "\"%" + key + "%\""; } } }
Source:
<code>@Override @Nullable public T read(JsonReader in) throws IOException { <START> JsonElement tree = adapter.read(in); T deserialized = delegate.fromJsonTree(tree); <END> return allRequiredFieldsPresent(deserialized, requiredFields) ? deserialized : null; }</code><technical_language>this delegate.read(in)? means get adapter for JsonElement.class. If current implementation, write need updated adapter.write</technical_language>

Target:
@Override @Nullable public T read(JsonReader in) throws IOException { T deserialized = delegate.read(in); return allRequiredFieldsPresent(deserialized, requiredFields) ? deserialized : null; }
Source:
<code>public void add(PipelineTimelineEntry pipelineTimelineEntry) { CaseInsensitiveString pipelineName = new CaseInsensitiveString(pipelineTimelineEntry.getPipelineName()); PipelineTimelineEntrySet pipelineTimelineEntrySet = initializePita(pipelineName); pipelineTimelineEntrySet.getNaturalOrderSet().add(pipelineTimelineEntry); pipelineTimelineEntrySet.getScheduledOrderSet().add(pipelineTimelineEntry); pipelineTimelineEntry.setInsertedBefore(naturalOrderAfter(pipelineTimelineEntry)); pipelineTimelineEntry.setInsertedAfter(naturalOrderBefore(pipelineTimelineEntry)); pipelineTimelineEntry.updateNaturalOrder(); <START> pipelineTimelineEntrySet.updateMaximumId(pipelineTimelineEntry.getId()); <END> }</code><technical_language>acquireAllWriteLocks is blocking in nature, means updates for pipelines, queue up. consider making acquireAllWriteLocks pipeline specific</technical_language>

Target:
public void add(PipelineTimelineEntry pipelineTimelineEntry) { CaseInsensitiveString pipelineName = new CaseInsensitiveString(pipelineTimelineEntry.getPipelineName()); PipelineTimelineEntrySet pipelineTimelineEntrySet = initializePipelineEntriesFor(pipelineName); pipelineTimelineEntrySet.getNaturalOrderSet().add(pipelineTimelineEntry); pipelineTimelineEntrySet.getScheduledOrderSet().add(pipelineTimelineEntry); pipelineTimelineEntry.setInsertedBefore(naturalOrderAfter(pipelineTimelineEntry)); pipelineTimelineEntry.setInsertedAfter(naturalOrderBefore(pipelineTimelineEntry)); pipelineTimelineEntry.updateNaturalOrder(); pipelineTimelineEntrySet.updateMaximumId(pipelineTimelineEntry.getId()); }
Source:
<code>public static void testLoadBalancing_slave() throws SQLException { Set<String> connectedHosts = new HashSet<String>(); Set<HostSpec> tryConnectedHosts = new HashSet<HostSpec>(); for (int i = 0; i < 20; ++i) { getConnection(secondary, true, true, fake1, master1, secondary1, secondary2); connectedHosts.add(getRemoteHostSpec()); tryConnectedHosts.addAll(hostStatusMap.keySet()); if (tryConnectedHosts.size() == 4) { break; } } <START> assertEquals("Never connected to all salve hosts", new HashSet<String>(asList(secondaryIP, <END> secondaryIP2)), connectedHosts); assertEquals("Never tried to connect to maste and fake node", 4, tryConnectedHosts.size()); getConnection(preferSecondary, false, true, fake1, master1, secondary1); assertRemote(secondaryIP); connectedHosts.clear(); for (int i = 0; i < 20; ++i) { getConnection(secondary, false, true, fake1, master1, secondary1, secondary2); connectedHosts.add(getRemoteHostSpec()); if (connectedHosts.size() == 2) { break; } } assertEquals("Never connected to all secondary hosts", new HashSet<String>(asList(secondaryIP, secondaryIP2)), connectedHosts); }</code><technical_language>salve -> secondary</technical_language>

Target:
public static void testLoadBalancing_slave() throws SQLException { Set<String> connectedHosts = new HashSet<String>(); Set<HostSpec> tryConnectedHosts = new HashSet<HostSpec>(); for (int i = 0; i < 20; ++i) { getConnection(secondary, true, true, fake1, master1, secondary1, secondary2); connectedHosts.add(getRemoteHostSpec()); tryConnectedHosts.addAll(hostStatusMap.keySet()); if (tryConnectedHosts.size() == 4) { break; } } assertEquals("Did not connect to all secondary hosts", new HashSet<String>(asList(secondaryIP, secondaryIP2)), connectedHosts); assertEquals("Did not attempt to connect to master and fake node", 4, tryConnectedHosts.size()); getConnection(preferSecondary, false, true, fake1, master1, secondary1); assertRemote(secondaryIP); connectedHosts.clear(); for (int i = 0; i < 20; ++i) { getConnection(secondary, false, true, fake1, master1, secondary1, secondary2); connectedHosts.add(getRemoteHostSpec()); if (connectedHosts.size() == 2) { break; } } assertEquals("Did not connect to all secondary hosts", new HashSet<String>(asList(secondaryIP, secondaryIP2)), connectedHosts); }
Source:
<code>public void close() throws FlinkKafka011Exception { try { final KafkaTransactionState currentTransaction = currentTransaction(); if (currentTransaction != null) { flush(currentTransaction); switch (semantic) { case EXACTLY_ONCE: break; case AT_LEAST_ONCE: case NONE: currentTransaction.producer.close(0, TimeUnit.SECONDS); <START> break; <END> } } super.close(); } catch (Exception e) { asyncException = ExceptionUtils.firstOrSuppressed(e, asyncException); } finally { if (currentTransaction() != null) { IOUtils.closeQuietly(currentTransaction().producer); } pendingTransactions().forEach(transaction -> IOUtils.closeQuietly(transaction.getValue().producer) ); checkErroneous(); } }</code><technical_language>Technically speaking, close producer timeout zero is a producer. A more consistent approach call flush first, close producer 0 timeout. work for exactly-once at-least-once cases</technical_language>

Target:
public void close() throws FlinkKafka011Exception { try { final KafkaTransactionState currentTransaction = currentTransaction(); if (currentTransaction != null) { flush(currentTransaction); switch (semantic) { case EXACTLY_ONCE: break; case AT_LEAST_ONCE: case NONE: currentTransaction.producer.flush(); currentTransaction.producer.close(0, TimeUnit.SECONDS); break; } } super.close(); } catch (Exception e) { asyncException = ExceptionUtils.firstOrSuppressed(e, asyncException); } finally { if (currentTransaction() != null) { IOUtils.closeQuietly(currentTransaction().producer); } pendingTransactions().forEach(transaction -> IOUtils.closeQuietly(transaction.getValue().producer) ); checkErroneous(); } }
Source:
<code>public void test_parameters_retention() throws Exception { assumeTrue(ClassFileVersion.ofThisVm().isAtLeast(ClassFileVersion.JAVA_V8)); <START> assumeTrue(ClassFileVersion.ofThisVm().isLessThan(ClassFileVersion.JAVA_V9)); END> Class<?> typeWithParameters = new ByteBuddy() .subclass(Object.class) .defineMethod("foo", void.class, Visibility.PUBLIC) .withParameter(String.class, "bar") .intercept(StubMethod.INSTANCE) .make() .load(null) .getLoaded(); MockCreationSettings<?> settings = settingsFor(typeWithParameters); @SuppressWarnings("unchecked") Object proxy = mockMaker.createMock(settings, new MockHandlerImpl(settings)); assertThat(proxy.getClass()).isEqualTo(typeWithParameters); assertThat(new TypeDescription.ForLoadedType(typeWithParameters).getDeclaredMethods().filter(named("foo")) .getOnly().getParameters().getOnly().getName()).isEqualTo("bar"); }</code><technical_language>I additional change in logic here. Java 8 Java 9 (so Java 6 & 7). Is intentional change</technical_language>

Target:
public void test_parameters_retention() throws Exception { assumeTrue(ClassFileVersion.ofThisVm().isAtLeast(JAVA_V8)); assumeTrue(ClassFileVersion.ofThisVm().isLessThan(JAVA_V9)); Class<?> typeWithParameters = new ByteBuddy() .subclass(Object.class) .defineMethod("foo", void.class, Visibility.PUBLIC) .withParameter(String.class, "bar") .intercept(StubMethod.INSTANCE) .make() .load(null) .getLoaded(); MockCreationSettings<?> settings = settingsFor(typeWithParameters); @SuppressWarnings("unchecked") Object proxy = mockMaker.createMock(settings, new MockHandlerImpl(settings)); assertThat(proxy.getClass()).isEqualTo(typeWithParameters); assertThat(new TypeDescription.ForLoadedType(typeWithParameters).getDeclaredMethods().filter(named("foo")) .getOnly().getParameters().getOnly().getName()).isEqualTo("bar"); }
Source:
<code>public static Family getFamilyFor(Class<? extends Component> ...componentTypes){ BitSet bits = new BitSet(); <START> for (Class<? extends Component> componentType : componentTypes) { <END> bits.set(ComponentType.getIndexFor(componentType)); } String hash = bits.toString(); Family family = families.get(hash, null); if(family == null){ family = new Family(bits); families.put(hash, family); } return family; }</code><technical_language>this allocate memory for iterator? I custom collections this happen though. for certain</technical_language>

Target:
public static Family getFamilyFor(Class<? extends Component> ...componentTypes){ BitSet bits = new BitSet(); int typesLength = componentTypes.length; for(int i = 0; i < typesLength; i++){ bits.set(ComponentType.getIndexFor(componentTypes[i])); } String hash = bits.toString(); Family family = families.get(hash, null); if(family == null){ family = new Family(bits); families.put(hash, family); } return family; }
Source:
<code>public Content setOwners(Collection<Owner> owners) { this.owners.clear(); <START> if (owners != null) { <END> this.owners.addAll(owners); } return this; }</code><technical_language>perform null check call clear()</technical_language>

Target:
public Content setOwners(Collection<Owner> owners) { if (this.owners == null) { this.owners = new HashSet<Owner>(); } this.owners.clear(); if (owners != null) { this.owners.addAll(owners); } return this; }
Source:
<code>private void setAudioTrack() { audioTracks = player.getAvailableAudioTracks(); if (audioTracks != null) { String language = "eng"; for (AudioTrack track : audioTracks) { Log.d("MultiAudio activity", "MultiAudio track language is: " + track.getLanguage()); <START> if (TextUtils.equals(track.getLanguage(), language) && !track.equals(currentAudioTrack)) { <END> player.setAudioTrack(track); break; } } } }</code><technical_language>I track null her. Is right? add checking for null</technical_language>

Target:
private void setAudioTrack() { if (player == null) { Log.e(TAG, "Player is null"); return; } audioTracks = player.getAvailableAudioTracks(); if (audioTracks != null) { String language = "eng"; for (AudioTrack track : audioTracks) { Log.d(TAG, "MultiAudio track language is: " + track.getLanguage()); if (TextUtils.equals(track.getLanguage(), language) && currentAudioTrack != null && !track.equals(currentAudioTrack)) { player.setAudioTrack(track); break; } } } }
Source:
<code>public void tick(Level level) { super.tick(level); <START> if(this.contains == null && hit == false) <END> { timeEmpty++; if(timeEmpty >= TIME_FLOAT_UPWARDS) { this.hit(); addToLog("[BUBBLE]\t is empty and floating upwards"); } } if(this.contains == null && hit == true) { timeEmpty++; if(timeEmpty >= TIME_KILL) { this.kill(); addToLog("[BUBBLE]\t was empty and popped"); } } if(this.contains != null) { timeContained++; if(timeContained >= this.contains.getCaughtTime()) { this.contains.revive(); this.contains.setLocation(this.location); level.addUnit(this.contains); this.kill(); } } }</code><technical_language>Expression simplified. [CheckStyle] <logic</technical_language>

Target:
public void tick(Level level) { super.tick(level); if(this.contains == null) { timeEmpty++; if(!hit) { floatUpwards(); } else { killBubble(); } } else { timeContained++; if(timeContained >= this.contains.getCaughtTime()) { this.contains.revive(); this.contains.setLocation(this.location); level.addUnit(this.contains); this.kill(); } } }
Source:
<code>public boolean hasNext() { if (!hasNext.isPresent()) { try { <START> jobClient.getJobExecutionResult(Thread.currentThread().getContextClassLoader()).get(); <END> } catch (Exception e) { throw new TableException("Failed to wait job finish", e); } hasNext = Optional.of(true); } return hasNext.get(); }</code><technical_language>classloader configurable for this class pass context classloader higher in stack. TableEnvironment soon (see FLINK-15635)</technical_language>

Target:
public boolean hasNext() { if (hasNext == null) { try { jobClient.getJobExecutionResult(classLoader).get(); } catch (Exception e) { throw new TableException("Failed to wait job finish", e); } hasNext = true; } return hasNext; }
Source:
<code>public boolean promptPassword(String msg) { <START> CredentialItem.Password p = new CredentialItem.Password(); <END> if (provider.get(uri, p)) { password = new String(p.getValue()); return true; } else { CredentialItem.StringType v = newPrompt(msg); if (provider.get(uri, v)) { password = v.getValue(); return true; } else { password = null; return false; } } }</code><technical_language>This discards "msg" argument JSch. this class needs a new constructor allows pass in msg default text</technical_language>

Target:
public boolean promptPassword(String msg) { CredentialItem.Password p = new CredentialItem.Password(msg); if (provider.get(uri, p)) { password = new String(p.getValue()); return true; } else { CredentialItem.StringType v = newPrompt(msg); if (provider.get(uri, v)) { password = v.getValue(); return true; } else { password = null; return false; } } }
Source:
<code>public static Method fromString(String string) { Method method = null; switch (string) { case "GET": method = GET; break; case "POST": method = POST; break; case "PUT": method = PUT; break; case "DELETE": method = DELETE; break; <START> default: <END> break; } return method; }</code><technical_language>Is correct default null throw</technical_language>

Target:
public static Method fromString(String string) { Method method; switch (string) { case "GET": method = GET; break; case "POST": method = POST; break; case "PUT": method = PUT; break; case "DELETE": method = DELETE; break; default: throw new IllegalArgumentException("Invalid http method: <" + string + ">"); } return method; }
Source:
<code>public void testLockingInterruptiblyCanBeInterrupted() throws Exception { Lock lock = new ReentrantLock(); <START> Exchanger<Thread> testBackgroundThreadExchanger = new Exchanger<>(); <END> Future<Object> future = executor.submit(() -> { testBackgroundThreadExchanger.exchange(Thread.currentThread()); lockingInterruptibly(lock, () -> { throw new AssertionError("test background thread got the lock"); }); throw new AssertionError("lockingInterruptibly returned, InterruptedException was expected"); }); locking(lock, () -> { Thread testBackgroundThread = testBackgroundThreadExchanger.exchange(null, 5, SECONDS); Thread.sleep(40); testBackgroundThread.interrupt(); }); try { future.get(5, SECONDS); fail("ExecutionException was expected"); } catch (ExecutionException expected) { assertTrue(expected.getCause() instanceof InterruptedException); } }</code><technical_language>This is long for a local variable name. exchanger fine</technical_language>

Target:
public void testLockingInterruptiblyCanBeInterrupted() throws Exception { Lock lock = new ReentrantLock(); Exchanger<Thread> exchanger = new Exchanger<>(); Future<Object> future = executor.submit(() -> { exchanger.exchange(Thread.currentThread()); lockingInterruptibly(lock, () -> { throw new AssertionError("test background thread got the lock"); }); throw new AssertionError("lockingInterruptibly returned, InterruptedException was expected"); }); locking(lock, () -> { Thread testBackgroundThread = exchanger.exchange(null, 5, SECONDS); Thread.sleep(40); testBackgroundThread.interrupt(); }); try { future.get(5, SECONDS); fail("ExecutionException was expected"); } catch (ExecutionException expected) { if (!(expected.getCause() instanceof InterruptedException)) { fail("Expected failure caused by interruption", expected); } } }
Source:
<code>private void setBuildsAndWorkspacesDir() { String newBuildsDir = SystemProperties.getString(BUILDS_DIR_PROP); if (newBuildsDir != null && !buildsDir.equals(newBuildsDir)) { LOGGER.log(Level.WARNING, "Changing builds directories from {0} to {1}. Beware that no automated data migration will occur.", new String[]{buildsDir, newBuildsDir}); <START> buildsDir = newBuildsDir; <END> } String newWorkspacesDir = SystemProperties.getString(WORKSPACES_DIR_PROP); if (newWorkspacesDir != null && !workspaceDir.equals(newBuildsDir)) { LOGGER.log(Level.WARNING, "Changing workspaces directories from {0} to {1}. Beware that no automated data migration will occur.", new String[]{workspaceDir, newWorkspacesDir}); workspaceDir = newWorkspacesDir; } }</code><technical_language>need save(), I suspect</technical_language>

Target:
private void setBuildsAndWorkspacesDir() throws IOException, InvalidBuildsDir { boolean mustSave = false; String newBuildsDir = SystemProperties.getString(BUILDS_DIR_PROP); if (newBuildsDir != null && !buildsDir.equals(newBuildsDir)) { checkRawBuildsDir(newBuildsDir); LOGGER.log(Level.WARNING, "Changing builds directories from {0} to {1}. Beware that no automated data migration will occur.", new String[]{buildsDir, newBuildsDir}); buildsDir = newBuildsDir; mustSave = true; } else if (!isDefaultBuildDir()) { LOGGER.log(Level.INFO, "Using non default builds directories: {0}.", buildsDir); } String newWorkspacesDir = SystemProperties.getString(WORKSPACES_DIR_PROP); if (newWorkspacesDir != null && !workspaceDir.equals(newWorkspacesDir)) { LOGGER.log(Level.WARNING, "Changing workspaces directories from {0} to {1}. Beware that no automated data migration will occur.", new String[]{workspaceDir, newWorkspacesDir}); workspaceDir = newWorkspacesDir; mustSave = true; } else if (!isDefaultWorkspaceDir()) { LOGGER.log(Level.INFO, "Using non default workspaces directories: {0}.", workspaceDir); } if (mustSave) { save(); } }
Source:
<code>private String createLiveInstanceWithUniqueName() { String hostname = "coordinator" + randomGenerator.nextInt(10000); try { hostname = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException uhe) { LOG.error(uhe.getMessage()); } long timestamp = System.currentTimeMillis(); String instanceName = String.format("%s-%d", hostname, timestamp); String znodePath = KeyBuilder.liveInstance(_cluster, instanceName); if (_zkclient.exists(znodePath)) { try { int randomInt = randomGenerator.nextInt(10); Thread.sleep(_instanceNameRetryWaitMs + randomInt); } catch (InterruptedException e) { <START> e.printStackTrace(); <END> } _instanceNameRetryWaitMs *= 2; LOG.info("Detected instance name conflicts."); return createLiveInstanceWithUniqueName(); } _zkclient.ensurePath(KeyBuilder.liveInstances(_cluster)); try{ _zkclient.create(KeyBuilder.liveInstance(_cluster, instanceName), "", CreateMode.EPHEMERAL); } catch (ZkNodeExistsException nee) { return createLiveInstanceWithUniqueName(); } _zkclient.ensurePath(KeyBuilder.instance(_cluster, instanceName)); return instanceName; }</code><technical_language>This a LOG.warn() possibly return</technical_language>

Target:
private String createLiveInstanceWithUniqueName() { _zkclient.ensurePath(KeyBuilder.liveInstances(_cluster)); String hostname = "coordinator" + randomGenerator.nextInt(10000); try { hostname = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException uhe) { LOG.error(uhe.getMessage()); } String instanceName; while(true) { long timestamp = System.currentTimeMillis(); instanceName = String.format("%s-%d", hostname, timestamp); String znodePath = KeyBuilder.liveInstance(_cluster, instanceName); if (_zkclient.exists(znodePath)) { int sleepDuration = _instanceNameRetryWaitMs + randomGenerator.nextInt(10); try { Thread.sleep(sleepDuration); } catch (InterruptedException e) { LOG.warn("Failed to sleep " + sleepDuration + "for retrying unique instance name " + e.getMessage()); } _instanceNameRetryWaitMs *= 2; LOG.info("Detected instance name conflict, retry again after " + _instanceNameRetryWaitMs + " milliseconds"); continue; } try{ _zkclient.create(KeyBuilder.liveInstance(_cluster, instanceName), "", CreateMode.EPHEMERAL); } catch (ZkNodeExistsException nee) { _instanceNameRetryWaitMs *= 2; LOG.info("Detected instance name conflict, retry again after " + _instanceNameRetryWaitMs + " milliseconds"); continue; } _zkclient.ensurePath(KeyBuilder.instance(_cluster, instanceName)); break; } return instanceName; }