auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void markCanBeCompleted(Long id) { completedOperationIds.offer(id); <START> if (outstandingOperationsCount.decrementAndGet() == 0) { <END> synchronized (this) { notify(); } } }</code><technical_language>if markCanBeCompleted(x) is called multiple times, outstandingOperationsCount get decremented multiple times</technical_language>

Target:
public void markCanBeCompleted(Long id) { completedOperationIds.offer(id); if (this.isFlushing.get() && completedOperationIds.size() == pendingOperationsWithSize.size()) { synchronized (this) { notify(); } } }
Source:
<code>public void onNext(final DataOperation<Long> op) { final LongKeyOperation operation = (LongKeyOperation) op; final String dataType = operation.getDataType(); final List<LongRange> dataKeyRanges = operation.getDataKeyRanges(); final Map<Integer, LongRange> blockToSubKeyRangeMap; final Iterator<LongRange> rangeIterator = dataKeyRanges.iterator(); if (rangeIterator.hasNext()) { final LongRange keyRange = rangeIterator.next(); blockToSubKeyRangeMap = router.resolveBlocks(keyRange); } else { <START> LOG.log(Level.SEVERE, "Invalid operation"); <END> return; } while (rangeIterator.hasNext()) { final LongRange keyRange = rangeIterator.next(); blockToSubKeyRangeMap.putAll(router.resolveBlocks(keyRange)); } final int numSubOps = blockToSubKeyRangeMap.size(); resultAggregator.registerOp(operation, numSubOps); if (!blockToSubKeyRangeMap.isEmpty()) { if (typeToBlocks.containsKey(dataType)) { enqueueOperation(operation, blockToSubKeyRangeMap); } else { if (operation.getOperationType() == DataOpType.PUT) { initBlocks(dataType); enqueueOperation(operation, blockToSubKeyRangeMap); } } } }</code><technical_language>Is swallow exceptional case</technical_language>

Target:
public void onNext(final DataOperation<Long> op) { final LongKeyOperation operation = (LongKeyOperation) op; final String dataType = operation.getDataType(); final List<LongRange> dataKeyRanges = operation.getDataKeyRanges(); final Map<Integer, Pair<Long, Long>> blockToSubKeyRangeMap; final Iterator<LongRange> rangeIterator = dataKeyRanges.iterator(); if (rangeIterator.hasNext()) { final LongRange keyRange = rangeIterator.next(); blockToSubKeyRangeMap = router.resolveBlocks(keyRange.getMinimumLong(), keyRange.getMaximumLong()); } else { LOG.log(Level.SEVERE, "Invalid operation"); resultAggregator.submitLocalResult(operation, Collections.EMPTY_MAP, Collections.EMPTY_LIST); return; } while (rangeIterator.hasNext()) { final LongRange keyRange = rangeIterator.next(); blockToSubKeyRangeMap.putAll(router.resolveBlocks(keyRange.getMinimumLong(), keyRange.getMaximumLong())); } final int numSubOps = blockToSubKeyRangeMap.size(); resultAggregator.registerOp(operation, numSubOps); if (!blockToSubKeyRangeMap.isEmpty()) { if (typeToBlocks.containsKey(dataType)) { enqueueOperation(operation, blockToSubKeyRangeMap); } else { if (operation.getOperationType() == DataOpType.PUT) { initBlocks(dataType); enqueueOperation(operation, blockToSubKeyRangeMap); } } } }
Source:
<code>public boolean hasEmptyAnnotationProcessors(Project project, String configurationString) { Optional<Configuration> configuration = getConfiguration(project, configurationString); <START> return configuration.map(files -> hasEmptyAnnotationProcessors(project, files)).orElse(true); <END> }</code><technical_language>suggestion return configuration.map(config -> hasEmptyAnnotationProcessors(project, config)).orElse(false); false if configuration is present</technical_language>

Target:
public boolean hasEmptyAnnotationProcessors(Project project, String configurationString) { Optional<Configuration> configuration = getConfiguration(project, configurationString); return configuration.map(config -> hasEmptyAnnotationProcessors(project, config)).orElse(false); }
Source:
<code>public void init() { super.init(); <START> setStorageDomainId(getDiskImage().getStorageIds().get(0)); <END> setStoragePoolId(getDiskImage().getStoragePoolId()); setImageGroupId(getDiskImage().getId()); setVm(vmDao .getVmsWithPlugInfo(getDiskImage().getId()) .stream() .filter(p -> p.getFirst().getStatus().isRunning()) .filter(p -> p.getSecond().isPlugged()) .map(Pair::getFirst) .findFirst() .orElse(null)); if (getVm() != null) { setVdsId(getVm().getRunOnVds()); } }</code><technical_language>note is executed validation phase, null</technical_language>

Target:
public void init() { super.init(); if (getDiskImage() == null) { return; } setStorageDomainId(getDiskImage().getStorageIds().get(0)); setStoragePoolId(getDiskImage().getStoragePoolId()); setImageGroupId(getDiskImage().getId()); setVm(vmDao .getVmsWithPlugInfo(getDiskImage().getId()) .stream() .filter(p -> p.getFirst().getStatus().isRunning()) .filter(p -> p.getSecond().isPlugged()) .map(Pair::getFirst) .findFirst() .orElse(null)); if (getVm() != null) { setVdsId(getVm().getRunOnVds()); } }
Source:
<code>public void requestActivityInfo(ResultReceiver result) { Bundle bundle = new Bundle(); <START> mLog.trace("requestedActivityInfo <END> uid=%").c(Binder.getCallingUid()).flush(); bundle.putParcelable(BatteryStats.RESULT_RECEIVER_CONTROLLER_KEY, reportActivityInfo()); result.send(0, bundle); }</code><technical_language>delete</technical_language>

Target:
public void requestActivityInfo(ResultReceiver result) { Bundle bundle = new Bundle(); mLog.trace("requestActivityInfo uid=%").c(Binder.getCallingUid()).flush(); bundle.putParcelable(BatteryStats.RESULT_RECEIVER_CONTROLLER_KEY, reportActivityInfo()); result.send(0, bundle); }
Source:
<code>private static Optional<KeychainAccessStrategy> constructKeychainAccess() { <START> if (!SystemUtils.IS_OS_LINUX) return Optional.empty(); <END> try { Class<?> clazz = Class.forName("org.cryptomator.keychain.LinuxSecretServiceKeychainAccessImpl"); KeychainAccessStrategy instance = (KeychainAccessStrategy) clazz.getDeclaredConstructor().newInstance(); if (instance.isSupported()) return Optional.of(instance); clazz = Class.forName("org.cryptomator.keychain.LinuxKDEWalletKeychainAccessImpl"); instance = (KeychainAccessStrategy) clazz.getDeclaredConstructor().newInstance(); return Optional.of(instance); } catch (Exception e) { return Optional.empty(); } }</code><technical_language>full "block" style, for short statements suggestion if (!SystemUtils.IS_OS_LINUX) { return Optional.empty(); }</technical_language>

Target:
private static Optional<KeychainAccessStrategy> constructKeychainAccess() { try { Class<?> clazz = Class.forName("org.cryptomator.keychain.LinuxSecretServiceKeychainAccessImpl"); KeychainAccessStrategy instance = (KeychainAccessStrategy) clazz.getDeclaredConstructor().newInstance(); if (instance.isSupported()) return Optional.of(instance); clazz = Class.forName("org.cryptomator.keychain.LinuxKDEWalletKeychainAccessImpl"); instance = (KeychainAccessStrategy) clazz.getDeclaredConstructor().newInstance(); return Optional.of(instance); } catch (Exception e) { return Optional.empty(); } }
Source:
<code>private void selectFirstDiffOrDisplayLabelViewer(final Comparison comparison) { if (comparison != null) { List<Diff> differences = comparison.getDifferences(); <START> if (differences.size() == 0) { <END> navigatable.fireOpen(new NoDifferencesCompareInput()); } else if (JFaceUtil.filterVisibleElement(getViewer(), IS_DIFF).size() == 0) { navigatable.fireOpen(new NoVisibleDifferencesCompareInput()); } else { navigatable.selectChange(INavigatable.FIRST_CHANGE); } } }</code><technical_language>"isEmpty()" instead of size() == 0</technical_language>

Target:
private void selectFirstDiffOrDisplayLabelViewer(final Comparison comparison) { if (comparison != null) { List<Diff> differences = comparison.getDifferences(); if (differences.isEmpty()) { navigatable.fireOpen(new NoDifferencesCompareInput()); } else if (JFaceUtil.filterVisibleElement(getViewer(), IS_DIFF).isEmpty()) { navigatable.fireOpen(new NoVisibleItemCompareInput()); } else { navigatable.selectChange(INavigatable.FIRST_CHANGE); } } }
Source:
<code>public void shutDownTask(TaskDefinition task) throws SchedulerException { if (Context.getSchedulerService().getTaskByName(task.getName()).getStarted()) { <START> Context.getSchedulerService().shutdownTask(task); <END> } }</code><technical_language>above. get rid of this class. is adding value. does, is business of service layer API</technical_language>

Target:
public void shutDownTask(TaskDefinition task) throws SchedulerException { Context.getSchedulerService().shutdownTask(task); }
Source:
<code>public static Description mergeDescriptions(Description testSuiteDescription, Description testCaseDescription) { Description description = new Description(); if (!StringUtils.isEmpty(testSuiteDescription.getValue())) { <START> description.setValue(testSuiteDescription.getValue() + "\n" + testCaseDescription.getValue()); <END> description.setType(testSuiteDescription.getType().equals(DescriptionType.MARKDOWN) ? DescriptionType.MARKDOWN : testCaseDescription.getType()); } return description; }</code><technical_language>double "\n"</technical_language>

Target:
public static Description mergeDescriptions(Description testSuiteDescription, Description testCaseDescription) { if (testSuiteDescription == null && testCaseDescription == null) { return null; } if (testSuiteDescription == null) { return testCaseDescription; } if (testCaseDescription == null) { return testSuiteDescription; } Description description = new Description(); if (!StringUtils.isEmpty(testSuiteDescription.getValue())) { DescriptionType descriptionType = testSuiteDescription.getType().equals(DescriptionType.MARKDOWN) ? DescriptionType.MARKDOWN : testCaseDescription.getType(); String descriptionValue = descriptionType.equals(DescriptionType.MARKDOWN) ? String.format("%s\n\n%s", testSuiteDescription.getValue(), testCaseDescription.getValue()) : String.format("%s\n%s", testSuiteDescription.getValue(), testCaseDescription.getValue()); description.setValue(descriptionValue); description.setType(descriptionType); } return description; }
Source:
<code>public CommandCallback getCallback() { <START> if (isDataOperationsByHSM()){ <END> return new ConcurrentChildCommandsExecutionCallback(); } return null; }</code><technical_language>inline that- return isDataOperationsByHSM() ? new .. : null;</technical_language>

Target:
public CommandCallback getCallback() { return isDataOperationsByHSM() ? new ConcurrentChildCommandsExecutionCallback() : null; }
Source:
<code>public void startViewTransition(@NonNull View view) { if (view.getParent() == this) { if (mTransitioningFragmentViews == null) { mTransitioningFragmentViews = new ArrayList<>(); } } <START> mTransitioningFragmentViews.add(view); <END> super.startViewTransition(view); }</code><technical_language>if view.getParent() != this, do want do this</technical_language>

Target:
public void startViewTransition(@NonNull View view) { if (view.getParent() == this) { if (mTransitioningFragmentViews == null) { mTransitioningFragmentViews = new ArrayList<>(); } mTransitioningFragmentViews.add(view); } super.startViewTransition(view); }
Source:
<code>public void getValue_asEmptyListAfterClassRemoved() { final String CLASS_NAME = "KingsAndQueens"; DynamicRealm realm = initializeDynamicRealm(CLASS_NAME); RealmResults<DynamicRealmObject> results = realm.where(CLASS_NAME).findAll(); assertEquals(results.get(0).getString("name"), "John"); assertEquals(results.first().getString("name"), "John"); assertEquals(results.last().getString("name"), "John"); removeClassFromDynamicRealm(realm, CLASS_NAME); <START> assertNull(results.get(0)); <END> try { results.first(); fail(); } catch (IndexOutOfBoundsException expected) { assertEquals("No results were found.", expected.getMessage()); } try { results.last(); fail(); } catch (IndexOutOfBoundsException expected) { assertEquals("No results were found.", expected.getMessage()); } realm.close(); }</code><technical_language>throw IndexOutOfBounds instead, first()</technical_language>

Target:
public void getValue_asEmptyListAfterClassRemoved() { final String CLASS_NAME = "KingsAndQueens"; DynamicRealm realm = initializeDynamicRealm(CLASS_NAME); RealmResults<DynamicRealmObject> results = realm.where(CLASS_NAME).findAll(); assertEquals(results.get(0).getString("name"), "John"); assertEquals(results.first().getString("name"), "John"); assertEquals(results.last().getString("name"), "John"); removeClassFromDynamicRealm(realm, CLASS_NAME); try { results.get(0); fail(); } catch (IndexOutOfBoundsException expected) { assertEquals("No results were found.", expected.getMessage()); } try { results.first(); fail(); } catch (IndexOutOfBoundsException expected) { assertEquals("No results were found.", expected.getMessage()); } try { results.last(); fail(); } catch (IndexOutOfBoundsException expected) { assertEquals("No results were found.", expected.getMessage()); } realm.close(); }
Source:
<code>public String toString() { return "BaseActivityObject{" + "Id='" + Id + '\'' + ", HRef='" + HRef + '\'' + ", Context='" + Context + '\'' + ", Type='" + Type + '\'' + ", Name='" + Name + '\'' + ", Location=" + Location + ", StartTime='" + StartTime + '\'' + ", EndTime='" + EndTime + '\'' + ", Duration='" + Duration + '\'' + ", Origin=" + Origin + ", AttributedTo=" + AttributedTo + ", SummaryMap=" + SummaryMap + ", NameMap=" + NameMap + <START> ", tirePressureObject=" + tirePressureObject + <END> '}'; }</code><technical_language>If other variable is in PascalCase, convention in file. TirePressureObject instead of tirePressureObject</technical_language>

Target:
public String toString() { return "BaseActivityObject{" + "Id='" + Id + '\'' + ", HRef='" + HRef + '\'' + ", Context='" + Context + '\'' + ", Type='" + Type + '\'' + ", Name='" + Name + '\'' + ", Location=" + Location + ", StartTime='" + StartTime + '\'' + ", EndTime='" + EndTime + '\'' + ", Duration='" + Duration + '\'' + ", Origin=" + Origin + ", AttributedTo=" + AttributedTo + ", SummaryMap=" + SummaryMap + ", NameMap=" + NameMap + '}'; }
Source:
<code>public MavenExecutionRequest setPom( File pom ) { this.pom = pom; <START> if ( this.pom != null && this.pom.getParentFile() != null ) <END> { this.setBaseDirectory( this.pom.getParentFile() ); } return this; }</code><technical_language>IIRC this wrong. a couple of plugins want rewrite pom (maven-shade-plugin, flatten-maven-plugin). This pom in target directory, cleaned up. However, basedir stay same</technical_language>

Target:
public MavenExecutionRequest setPom( File pom ) { this.pom = pom; return this; }
Source:
<code>public void write(byte[] b) throws IOException { int overflow = buffer(b, 0, b.length); <START> if (overflow > 0) <END> write(b, b.length - overflow, overflow); }</code><technical_language>style nit: missing braces, more of</technical_language>

Target:
public void write(byte[] b) throws IOException { int overflow = buffer(b, 0, b.length); if (overflow > 0) { write(b, b.length - overflow, overflow); } }
Source:
<code>public String toString() { <START> return String.format("float@0x%x=%s", Pointer.nativeValue(getPointer()), Float.toString(getValue())); <END> }</code><technical_language>DoubleByReference</technical_language>

Target:
public String toString() { return String.format("float@0x%x=%s", Pointer.nativeValue(getPointer()), getValue()); }
Source:
<code>public void restoreBinding(ContextModel contextModel) { BindingElement element = (BindingElement) getSelectedElement(); if (element == null) { return; } restoreBinding(element); refresh(contextModel); Object obj = element.getModelObject(); ParameterizedCommand cmd = null; if (obj instanceof ParameterizedCommand) { cmd = (ParameterizedCommand) obj; } else if (obj instanceof KeyBinding) { cmd = ((KeyBinding) obj).getParameterizedCommand(); } else { <START> return; <END> } boolean done = false; Iterator i = bindingElements.iterator(); while (i.hasNext() && !done) { BindingElement be = (BindingElement) i.next(); obj = be.getModelObject(); ParameterizedCommand pcmd = null; if (obj instanceof ParameterizedCommand) { pcmd = (ParameterizedCommand) obj; } else if (obj instanceof KeyBinding) { pcmd = ((KeyBinding) obj).getParameterizedCommand(); } if (cmd.equals(pcmd)) { done = true; setSelectedElement(be); } } }</code><technical_language>why? this if(obj == null) return</technical_language>

Target:
public void restoreBinding(ContextModel contextModel) { BindingElement element = (BindingElement) getSelectedElement(); if (element == null) { return; } restoreBinding(element); refresh(contextModel); Object obj = element.getModelObject(); ParameterizedCommand cmd = null; if (obj instanceof ParameterizedCommand) { cmd = (ParameterizedCommand) obj; } else if (obj instanceof KeyBinding) { cmd = ((KeyBinding) obj).getParameterizedCommand(); } Assert.isNotNull(cmd); boolean done = false; Iterator i = bindingElements.iterator(); while (i.hasNext() && !done) { BindingElement be = (BindingElement) i.next(); obj = be.getModelObject(); ParameterizedCommand pcmd = null; if (obj instanceof ParameterizedCommand) { pcmd = (ParameterizedCommand) obj; } else if (obj instanceof KeyBinding) { pcmd = ((KeyBinding) obj).getParameterizedCommand(); } if (cmd.equals(pcmd)) { done = true; setSelectedElement(be); } } }
Source:
<code>public static Text getSleepDeprivationMessage(final int idealDuration, final int avgSleepDebtDuration) { <START> final float avgSleepDebtHour = ((float) Math.round(avgSleepDebtDuration / 30) ) / 2; <END> if (avgSleepDebtHour == 1) { return new Text("The importance of sleep", String.format("For the last four nights, you got less than your ideal %d hours of sleep. ", idealDuration) + String.format("During those nights, you slept %.1f hour less than your nightly average.", avgSleepDebtHour)); } return new Text("The importance of sleep", String.format("For the last four nights, you got less than your ideal %d hours of sleep. ", idealDuration) + String.format("During those nights, you slept %.1f hours less than your nightly average.", avgSleepDebtHour)); }</code><technical_language>intend integer division here? is is implemented now. (you'd change 30 --> 30. 30.0</technical_language>

Target:
public static Text getSleepDeprivationMessage(final int idealDuration, final int avgSleepDebtDuration) { final float avgSleepDebtHour = ((float) (avgSleepDebtDuration / 30) ) / 2.0f; final DecimalFormat df = new DecimalFormat("0.###"); String plural = "s"; if (avgSleepDebtHour == 1.0f) { plural = ""; } return new Text("The importance of sleep", String.format("For the last four nights, you got less than your ideal %d hours of sleep. ", idealDuration) + String.format("During those nights, you slept %s hour%s less than your nightly average.", df.format(avgSleepDebtHour), plural)); }
Source:
<code>public static Map<String, String> getKiePMMLTreeModelSourcesMap(final DataDictionary dataDictionary, final TreeModel model, final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap, final String packageName) { logger.trace("getKiePMMLTreeModelSourcesMap {}", dataDictionary, model, packageName); CompilationUnit cloneCU = getKiePMMLModelCompilationUnit(dataDictionary, model, fieldTypeMap, packageName, KIE_PMML_TREE_MODEL_TEMPLATE_JAVA, KIE_PMML_TREE_MODEL_TEMPLATE); String className = getSanitizedClassName(model.getModelName()); ClassOrInterfaceDeclaration modelTemplate = cloneCU.getClassByName(className) <START> .orElseThrow(() -> new KiePMMLException(MAIN_CLASS_NOT_FOUND)); <END> final ConstructorDeclaration constructorDeclaration = modelTemplate.getDefaultConstructor().orElseThrow(() -> new KiePMMLInternalException(String.format("Missing default constructor in ClassOrInterfaceDeclaration %s ", modelTemplate.getName()))); setSuperInvocation(model, constructorDeclaration, modelTemplate.getName()); Map<String, String> toReturn = new HashMap<>(); String fullClassName = packageName + "." + className; toReturn.put(fullClassName, cloneCU.toString()); return toReturn; }</code><technical_language>please add className error message</technical_language>

Target:
public static Map<String, String> getKiePMMLTreeModelSourcesMap(final DataDictionary dataDictionary, final TreeModel model, final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap, final String packageName) { logger.trace("getKiePMMLTreeModelSourcesMap {}", dataDictionary, model, packageName); CompilationUnit cloneCU = getKiePMMLModelCompilationUnit(dataDictionary, model, fieldTypeMap, packageName, KIE_PMML_TREE_MODEL_TEMPLATE_JAVA, KIE_PMML_TREE_MODEL_TEMPLATE); String className = getSanitizedClassName(model.getModelName()); ClassOrInterfaceDeclaration modelTemplate = cloneCU.getClassByName(className) .orElseThrow(() -> new KiePMMLException(MAIN_CLASS_NOT_FOUND + ": " + className)); final ConstructorDeclaration constructorDeclaration = modelTemplate.getDefaultConstructor().orElseThrow(() -> new KiePMMLInternalException(String.format("Missing default constructor in ClassOrInterfaceDeclaration %s ", modelTemplate.getName()))); setSuperInvocation(model, constructorDeclaration, modelTemplate.getName()); Map<String, String> toReturn = new HashMap<>(); String fullClassName = packageName + "." + className; toReturn.put(fullClassName, cloneCU.toString()); return toReturn; }
Source:
<code>public void runByTrigger() throws Exception { SampleComputedFolder s = r.jenkins.createProject(SampleComputedFolder.class, "s"); s.assertItemNames(0); s.addTrigger(new PeriodicFolderTrigger("1m")); <START> Thread.sleep(65000); <END> s.assertItemNames(1); }</code><technical_language>Ouch, this test runs significantly slower. For purposes of test suffice call .run() trigger</technical_language>

Target:
public void runByTrigger() throws Exception { SampleComputedFolder s = r.jenkins.createProject(SampleComputedFolder.class, "s"); s.assertItemNames(0); PeriodicFolderTrigger t = new PeriodicFolderTrigger("1m"); s.addTrigger(t); t.run(); r.waitUntilNoActivity(); s.assertItemNames(1); }
Source:
<code>public static boolean isAuthenticated(HttpServletRequest request) { HttpSession session = request.getSession(false); return session != null && session.getAttribute(Constants.AUTHENTICATED_KEY) != null <START> && (boolean) session.getAttribute(Constants.AUTHENTICATED_KEY); <END> }</code><technical_language>maybe? return session != null && Boolean.valueOf(session.getAttribute(".."));</technical_language>

Target:
public static boolean isAuthenticated(HttpServletRequest request) { HttpSession session = request.getSession(false); return session != null && Boolean.valueOf((Boolean) session.getAttribute(Constants.AUTHENTICATED_KEY)); }
Source:
<code>Journal(String dataDir, int maxEntriesToJournal, int maxEntriesToReturn) { journal = new ConcurrentSkipListMap<>(); <START> recentCrcs = new HashMap<>(); <END> this.maxEntriesToJournal = maxEntriesToJournal; this.maxEntriesToReturn = maxEntriesToReturn; this.currentNumberOfEntries = new AtomicInteger(0); this.dataDir = dataDir; }</code><technical_language>reminder change this ConcurrentHashMap</technical_language>

Target:
Journal(String dataDir, int maxEntriesToJournal, int maxEntriesToReturn) { journal = new ConcurrentSkipListMap<>(); recentCrcs = new ConcurrentHashMap<>(); this.maxEntriesToJournal = maxEntriesToJournal; this.maxEntriesToReturn = maxEntriesToReturn; this.currentNumberOfEntries = new AtomicInteger(0); this.dataDir = dataDir; }
Source:
<code>public void setNoMorePages() { checkState(!Thread.holdsLock(this), "Can not set no more pages while holding a lock on this"); state.compareAndSet(OPEN, NO_MORE_PAGES); state.compareAndSet(NO_MORE_BUFFERS, FLUSHING); memoryManager.setNoBlockOnFull(); masterBuffer.setNoMorePages(); <START> for (ClientBuffer clientBuffer : safeGetBuffersSnapshot()) { <END> if (masterBuffer.isEmpty()) { clientBuffer.setNoMorePages(); } else { clientBuffer.loadPagesIfNecessary(masterBuffer); } } checkFlushComplete(); }</code><technical_language>this is correct. ClientBuffer a push a pull mode. push mode enueuPages setNoMorePages pull mode loadPagesIfNecessary. confident setNoMorePages in a pull mode do want. Instead, I suggest simply call loadPagesIfNecessary ClientBuffer modify loadPagesIfNecessary properly handle called a !pagesSupplier.mayHaveMorePages()</technical_language>

Target:
public void setNoMorePages() { checkState(!Thread.holdsLock(this), "Can not set no more pages while holding a lock on this"); state.compareAndSet(OPEN, NO_MORE_PAGES); state.compareAndSet(NO_MORE_BUFFERS, FLUSHING); memoryManager.setNoBlockOnFull(); masterBuffer.setNoMorePages(); for (ClientBuffer clientBuffer : safeGetBuffersSnapshot()) { clientBuffer.loadPagesIfNecessary(masterBuffer); } checkFlushComplete(); }
Source:
<code>public static int getPreferredBrowser() { <START> return isMacOS ? SWT.WEBKIT : SWT.WEBKIT; <END> }</code><technical_language>create a test for WEBKIT based preview Linux. reproduce steps in <LINK_0></technical_language>

Target:
public static int getPreferredBrowser() { return isMacOS ? SWT.WEBKIT : SWT.MOZILLA; }
Source:
<code>public void testPutAllMapNull() throws Exception { final Map<String, String> originalStoreContent = getEntryMap(KEY_SET_A, KEY_SET_B); final FakeStore fakeStore = new FakeStore(originalStoreContent); <START> this.store = spy(fakeStore); <END> final Ehcache<String, String> ehcache = getEhcache(); try { ehcache.putAll(null); fail(); } catch (NullPointerException e) { } verify(cacheEventListener, never()).onEvent(Matchers.<CacheEvent<String, String>>any()); }</code><technical_language>a bit picky here, tests clearer replacing 3 lines a call a method, this.store = getStore(KEY_SET_A, KEY_SET_B); private Store getStore(Set<String>... sets) { Map<String, String> originalStoreContent = getEntryMap(sets); FakeStore fakeStore = new FakeStore(originalStoreContent); return spy(fakeStore); } especially a getCache() method encapsulate cache creation</technical_language>

Target:
public void testPutAllMapNull() throws Exception { buildStore(getEntryMap(KEY_SET_A, KEY_SET_B)); final Ehcache<String, String> ehcache = getEhcache(); try { ehcache.putAll(null); fail(); } catch (NullPointerException e) { } verify(cacheEventListener, never()).onEvent(Matchers.<CacheEvent<String, String>>any()); }
Source:
<code>public OAuth2InitialClientMessage getInitialResponse() throws AuthenticationMechanismException { final CredentialCallback credentialCallback = new CredentialCallback(BearerTokenCredential.class); try { MechanismUtil.handleCallbacks(this.mechanismName, this.callbackHandler, credentialCallback); } catch (UnsupportedCallbackException e) { throw ElytronMessages.log.mechCallbackHandlerDoesNotSupportUserName(this.mechanismName, e); } assertTrue(credentialCallback.isCredentialTypeSupported(BearerTokenCredential.class)); BearerTokenCredential credential = credentialCallback.getCredential(BearerTokenCredential.class); if (credential == null || credential.getToken() == null) { <START> throw ElytronMessages.log.mechNoTokenGiven(this.mechanismName); <END> } final String token = credential.getToken(); final ByteStringBuilder encoded = new ByteStringBuilder(); encoded.append("n").append(","); if (this.authorizationId != null) { encoded.append('a').append('='); StringPrep.encode(this.authorizationId, encoded, StringPrep.PROFILE_SASL_STORED | StringPrep.MAP_SCRAM_LOGIN_CHARS); } encoded.append(",").append(KV_DELIMITER).append("auth").append("=").append("Bearer").append(" ").append(token).append(KV_DELIMITER); return new OAuth2InitialClientMessage(null, null, encoded.toArray()); }</code><technical_language>change this, cool trick do is: final String token = credentialCallback.applyToCredential(BearerTokenCredential.class, Credential::getToken); save a couple lines of code; check if token is null</technical_language>

Target:
public OAuth2InitialClientMessage getInitialResponse() throws AuthenticationMechanismException { final CredentialCallback credentialCallback = new CredentialCallback(BearerTokenCredential.class); try { MechanismUtil.handleCallbacks(this.mechanismName, this.callbackHandler, credentialCallback); } catch (UnsupportedCallbackException e) { throw ElytronMessages.log.mechCallbackHandlerDoesNotSupportUserName(this.mechanismName, e); } assertTrue(credentialCallback.isCredentialTypeSupported(BearerTokenCredential.class)); final String token = credentialCallback.applyToCredential(BearerTokenCredential.class, BearerTokenCredential::getToken); if (token == null) { throw ElytronMessages.log.mechNoTokenGiven(this.mechanismName); } final ByteStringBuilder encoded = new ByteStringBuilder(); encoded.append("n").append(","); if (this.authorizationId != null) { encoded.append('a').append('='); StringPrep.encode(this.authorizationId, encoded, StringPrep.PROFILE_SASL_STORED | StringPrep.MAP_SCRAM_LOGIN_CHARS); } encoded.append(",").append(KV_DELIMITER).append("auth").append("=").append("Bearer").append(" ").append(token).append(KV_DELIMITER); return new OAuth2InitialClientMessage(null, null, encoded.toArray()); }
Source:
<code>protected List<CandidateCellForSweeping> computeNext() { if (end) { return endOfData(); } else { List<CandidateCellForSweeping> candidates = Lists.newArrayList(); while (candidates.isEmpty() && rawIter.hasNext()) { List<CassandraRawCellValue> cols = rawIter.next(); for (CassandraRawCellValue col : cols) { <START> processColumn(col, candidates); <END> } } if (candidates.isEmpty()) { end = true; if (!currentTimestamps.isEmpty()) { return ImmutableList.of(createCandidate()); } else { return endOfData(); } } else { return candidates; } } }</code><technical_language>I @Output variable there. in 'Effective Java' similar tones warning things. easy sidestep in this case, candidates is added to. change this line candidates.addAll(collectCandidatesForSweeping(col)), create + return a fresh list in collectCandidatesForSweeping (also shining a light intent of processColumn while it)</technical_language>

Target:
protected List<CandidateCellForSweeping> computeNext() { if (reachedEnd) { return endOfData(); } else { List<CandidateCellForSweeping> candidates = Lists.newArrayList(); while (candidates.isEmpty() && rawIter.hasNext()) { List<CassandraRawCellValue> cols = rawIter.next(); for (CassandraRawCellValue col : cols) { processColumn(col).ifPresent(candidates::add); } } if (candidates.isEmpty()) { reachedEnd = true; if (!currentTimestamps.isEmpty()) { return ImmutableList.of(createCandidate()); } else { return endOfData(); } } else { return candidates; } } }
Source:
<code><START> protected @C.Accessibility int parseAccessibility(List<Descriptor> accessibilityDescriptors) { <END> for (int i = 0; i < accessibilityDescriptors.size(); i++) { Descriptor descriptor = accessibilityDescriptors.get(i); if ("urn:mpeg:dash:role:2011".equalsIgnoreCase(descriptor.schemeIdUri) && descriptor.value != null) { switch (descriptor.value){ case "description": return C.ACCESSIBILITY_DESCRIPTION; case "enhanced-audio-intelligibility": return C.ACCESSIBILITY_ENHANCED_AUDIO_INTELLIGIBILITY; case "caption": return C.ACCESSIBILITY_CAPTION; case "sign": return C.ACCESSIBILITY_SIGN; default: return C.ACCESSIBILITY_UNSET; } } if ("urn:tva:metadata:cs:AudioPurposeCS:2007".equalsIgnoreCase(descriptor.schemeIdUri) && descriptor.value != null) { switch (descriptor.value){ case "1": return C.ACCESSIBILITY_ENHANCED_AUDIO_INTELLIGIBILITY; case "2": return C.ACCESSIBILITY_CAPTION; default: return C.ACCESSIBILITY_UNSET; } } } return C.ACCESSIBILITY_UNSET; }</code><technical_language>If suggested approach, this method return C.RoleFlags, is slightly strange. strange DASH-IF separated of urn:mpeg:dash:role:2011 Role Accessibility elements start with, in opinion :)... OR'd parseRole result get final flags. a single method parse "urn:mpeg:dash:role:2011" call parseRole parseAccessibility. I want handle "description" appearing Role elements well</technical_language>

Target:
protected @C.RoleFlags int parseAccessibility(List<Descriptor> accessibilityDescriptors) { @C.RoleFlags int result = 0; for (int i = 0; i < accessibilityDescriptors.size(); i++) { Descriptor descriptor = accessibilityDescriptors.get(i); if ("urn:mpeg:dash:role:2011".equalsIgnoreCase(descriptor.schemeIdUri)) { result |= parseRoleSchemeValue(descriptor.value); } else if ("urn:tva:metadata:cs:AudioPurposeCS:2007".equalsIgnoreCase(descriptor.schemeIdUri)) { result |= parseAudioPurposeValue(descriptor.value); } } return result; }
Source:
<code>private void updateRngDevice() { if (getParameters().isUpdateRngDevice()) { VdcQueryReturnValue query = getBackend().runInternalQuery(VdcQueryType.GetRngDevice, new IdQueryParameters(getParameters().getVmId())); @SuppressWarnings("unchecked") List<VmRngDevice> rngDevs = query.getReturnValue(); if (getParameters().getRngDevice() != null) { <START> getParameters().getRngDevice().setVmId(getParameters().getVmId()); <END> } VdcReturnValueBase rngCommandResult = null; if (rngDevs.isEmpty()) { if (getParameters().getRngDevice() != null) { RngDeviceParameters params = new RngDeviceParameters(getParameters().getRngDevice(), true); rngCommandResult = getBackend().runInternalAction(VdcActionType.AddRngDevice, params); } } else { if (getParameters().getRngDevice() == null) { RngDeviceParameters params = new RngDeviceParameters(rngDevs.get(0), true); rngCommandResult = getBackend().runInternalAction(VdcActionType.RemoveRngDevice, params); } else { RngDeviceParameters params = new RngDeviceParameters(getParameters().getRngDevice(), true); params.getRngDevice().setDeviceId(rngDevs.get(0).getDeviceId()); rngCommandResult = getBackend().runInternalAction(VdcActionType.UpdateRngDevice, params); } } if (rngCommandResult != null && !rngCommandResult.getSucceeded()) { getReturnValue().setSucceeded(false); } } }</code><technical_language>if get device vmId, need set here</technical_language>

Target:
private void updateRngDevice() { if (getParameters().isUpdateRngDevice()) { VdcQueryReturnValue query = getBackend().runInternalQuery(VdcQueryType.GetRngDevice, new IdQueryParameters(getParameters().getVmId())); @SuppressWarnings("unchecked") List<VmRngDevice> rngDevs = query.getReturnValue(); VdcReturnValueBase rngCommandResult = null; if (rngDevs.isEmpty()) { if (getParameters().getRngDevice() != null) { RngDeviceParameters params = new RngDeviceParameters(getParameters().getRngDevice(), true); rngCommandResult = getBackend().runInternalAction(VdcActionType.AddRngDevice, params); } } else { if (getParameters().getRngDevice() == null) { RngDeviceParameters params = new RngDeviceParameters(rngDevs.get(0), true); rngCommandResult = getBackend().runInternalAction(VdcActionType.RemoveRngDevice, params); } else { RngDeviceParameters params = new RngDeviceParameters(getParameters().getRngDevice(), true); params.getRngDevice().setDeviceId(rngDevs.get(0).getDeviceId()); rngCommandResult = getBackend().runInternalAction(VdcActionType.UpdateRngDevice, params); } } if (rngCommandResult != null && !rngCommandResult.getSucceeded()) { getReturnValue().setSucceeded(false); } } }
Source:
<code>private void updateHostList(String searchFilter) { Provider provider = (Provider) getProviders().getSelectedItem(); if (provider != null ) { AsyncQuery getHostsQuery = new AsyncQuery(); getHostsQuery.asyncCallback = new INewAsyncCallback() { @Override public void onSuccess(Object model, Object result) { ArrayList<VDS> hosts = (ArrayList<VDS>) result; ListModel hostNameListModel = getExternalHostName(); hosts.add(0, null); hostNameListModel.setItems(hosts); hostNameListModel.setIsChangable(true); <START> getProviderSearchFilter().setIsChangable(true); <END> getProviderSearchFilterLabel().setIsChangable(true); getUpdateHostsCommand().setIsExecutionAllowed(true); } }; AsyncDataProvider.GetExternalProviderHostList(getHostsQuery, provider.getId(), true, searchFilter); } else { getExternalHostName().setItems(null); getExternalHostName().setIsChangable(false); getProviderSearchFilter().setIsChangable(false); getProviderSearchFilterLabel().setIsChangable(false); getUpdateHostsCommand().setIsExecutionAllowed(false); } }</code><technical_language>this block multiple time. extract a method- enableSearchHost(boolean enable)</technical_language>

Target:
private void updateHostList(String searchFilter) { Provider provider = (Provider) getProviders().getSelectedItem(); if (provider != null ) { AsyncQuery getHostsQuery = new AsyncQuery(); getHostsQuery.asyncCallback = new INewAsyncCallback() { @Override public void onSuccess(Object model, Object result) { ArrayList<VDS> hosts = (ArrayList<VDS>) result; ListModel hostNameListModel = getExternalHostName(); hosts.add(0, null); hostNameListModel.setItems(hosts); hostNameListModel.setIsChangable(true); setEnableSearchHost(true); } }; AsyncDataProvider.GetExternalProviderHostList(getHostsQuery, provider.getId(), true, searchFilter); } else { getExternalHostName().setItems(null); getExternalHostName().setIsChangable(false); setEnableSearchHost(false); } }
Source:
<code>boolean run() throws IOException, InterruptedException { log("Docker Build"); String imageId = buildImage(); if (imageId == null) { return false; } log("Docker Build Response : " + imageId); <START> run.addAction(new DockerBuildImageAction(dockerApi.getDockerHost().getUri(), imageId, tagsToUse, cleanupWithJenkinsJobDelete, pushOnSuccess, noCache, pull)); <END> run.save(); if (pushOnSuccess) { log("Pushing " + tagsToUse); pushImages(); } if (cleanImages) { log("Cleaning local images [" + imageId + "]"); try { cleanImages(imageId); } catch (Exception ex) { log("Error attempting to clean images"); } } log("Docker Build Done"); return true; }</code><technical_language>This line is intolerably long - please construct new DockerBuildImageAction store in a local variable action call run.addAction(action); life easier if add more fields in future</technical_language>

Target:
boolean run() throws IOException, InterruptedException { log("Docker Build"); String imageId = buildImage(); if (imageId == null) { return false; } log("Docker Build Response : " + imageId); Action action = new DockerBuildImageAction(dockerApi.getDockerHost().getUri(), imageId, tagsToUse, cleanupWithJenkinsJobDelete, pushOnSuccess, noCache, pull); run.addAction(action); run.save(); if (pushOnSuccess) { log("Pushing " + tagsToUse); pushImages(); } if (cleanImages) { log("Cleaning local images [" + imageId + "]"); try { cleanImages(imageId); } catch (Exception ex) { log("Error attempting to clean images"); } } log("Docker Build Done"); return true; }
Source:
<code>public void close() throws Exception { try { database.close(); <START> } catch (LiquibaseException e){ <END> LOGGER.warn("Failed to close liquibase", e); } dataSource.stop(); }</code><technical_language>I remove catch block exception propagate (the method declares throw Exception) put dataSource.stop() call finally block of try-finally statement</technical_language>

Target:
public void close() throws Exception { try { database.close(); } finally { dataSource.stop(); } }
Source:
<code>private void internalInitialize(String machineName) { final WorkspaceImpl workspace = appContext.getWorkspace(); final RuntimeImpl runtime = workspace.getRuntime(); if (runtime == null) { return; } runtime .getMachineByName(machineName) .ifPresent( machine -> { Optional<ServerImpl> execAgentServer = machine.getServerByName(SERVER_EXEC_AGENT_WEBSOCKET_REFERENCE); execAgentServer.ifPresent( server -> initializer.initialize( machine.getName(), <START> singletonMap("url", wsAgentURLModifier.modify(server.getUrl())))); <END> }); }</code><technical_language>this is a wsagent. WsAgentURLModifier here</technical_language>

Target:
private void internalInitialize(String machineName) { final WorkspaceImpl workspace = appContext.getWorkspace(); final RuntimeImpl runtime = workspace.getRuntime(); if (runtime == null) { return; } runtime .getMachineByName(machineName) .ifPresent( machine -> { Optional<ServerImpl> execAgentServer = machine.getServerByName(SERVER_EXEC_AGENT_WEBSOCKET_REFERENCE); execAgentServer.ifPresent( server -> initializer.initialize( machine.getName(), singletonMap("url", agentURLModifier.modify(server.getUrl())))); }); }
Source:
<code>public static long hash(long seed, Slice data, int offset, int length) { checkPositionIndexes(0, offset + length, data.length()); Object base = data.getBase(); long address = data.getAddress() + offset; long hash; if (length >= 32) { hash = updateBody(seed, base, address, length - 32); } else { hash = seed + PRIME64_5; } hash += length; <START> int index = length & -32; <END> while (index <= length - 8) { hash = updateTail(hash, unsafe.getLong(base, address + index)); index += 8; } if (index <= length - 4) { hash = updateTail(hash, unsafe.getInt(base, address + index)); index += 4; } while (index < length) { hash = updateTail(hash, unsafe.getByte(base, address + index)); index++; } hash = finalShuffle(hash); return hash; }</code><technical_language>do this. This is a mask, -32 hard is</technical_language>

Target:
public static long hash(long seed, Slice data, int offset, int length) { checkPositionIndexes(0, offset + length, data.length()); Object base = data.getBase(); final long address = data.getAddress() + offset; long hash; if (length >= 32) { hash = updateBody(seed, base, address, length - 32); } else { hash = seed + PRIME64_5; } hash += length; int index = length & 0xFFFFFFE0; return updateTail(hash, base, address, index, length); }
Source:
<code>public RawPacket reverseTransform(RawPacket pkt) { boolean dropPkt = false; if ((ssrcAudioLevelExtID > 0) && ssrcAudioLevelDirection.allowsReceiving() && !pkt.isInvalid() && RTPHeader.VERSION == pkt.getVersion()) { byte level = pkt.extractSsrcAudioLevel(ssrcAudioLevelExtID); if (level == 127 ) { if (dropMutedAudioSourceInReverseTransform) { dropPkt = droppedMutedAudioSourceInReverseTransform < MAX_DROPPED_MUTED_AUDIO_SOURCE_IN_REVERSE_TRANSFORM; } else { pkt.setFlags(Buffer.FLAG_SILENCE | pkt.getFlags()); } } if (!dropPkt && (csrcAudioLevelDispatcher != null) && (level >= 0)) { long[] levels = new long[2]; levels[0] = pkt.getSSRCAsLong(); levels[1] = 127 - level; csrcAudioLevelDispatcher.addLevels(levels, pkt.getTimestamp()); } } <START> SequenceNumberRewriter rewriter = ssrcToRewriter.get(pkt.getSSRCAsLong()); <END> if (rewriter == null) { rewriter = new SequenceNumberRewriter(); ssrcToRewriter.put(pkt.getSSRCAsLong(), rewriter); } rewriter.rewrite( !dropPkt, pkt.getBuffer(), pkt.getOffset(), pkt.getLength()); if (dropPkt) { droppedMutedAudioSourceInReverseTransform++; return null; } else { droppedMutedAudioSourceInReverseTransform = 0; return pkt; } }</code><technical_language>@gpolitis fact rewriter is accessed lastN decision means packets reach (if write is "false" get here) Rewriter needs packets of ssrcs</technical_language>

Target:
public RawPacket reverseTransform(RawPacket pkt) { boolean dropPkt = false; if ((ssrcAudioLevelExtID > 0) && ssrcAudioLevelDirection.allowsReceiving() && !pkt.isInvalid() && RTPHeader.VERSION == pkt.getVersion()) { byte level = pkt.extractSsrcAudioLevel(ssrcAudioLevelExtID); if (level == 127 ) { if (dropMutedAudioSourceInReverseTransform) { dropPkt = droppedMutedAudioSourceInReverseTransform < MAX_DROPPED_MUTED_AUDIO_SOURCE_IN_REVERSE_TRANSFORM; } else { pkt.setFlags(Buffer.FLAG_SILENCE | pkt.getFlags()); } } if (!dropPkt && (csrcAudioLevelDispatcher != null) && (level >= 0)) { long[] levels = new long[2]; levels[0] = pkt.getSSRCAsLong(); levels[1] = 127 - level; csrcAudioLevelDispatcher.addLevels(levels, pkt.getTimestamp()); } } if (dropPkt) { droppedMutedAudioSourceInReverseTransform++; pkt.setFlags(Buffer.FLAG_DISCARD | pkt.getFlags()); } else { droppedMutedAudioSourceInReverseTransform = 0; } return pkt; }
Source:
<code>public long check(EC2Computer c) { if (!checkLock.tryLock()) { return 1; } else { try { if (this.clock == null){ <START> this.clock = Clock.systemUTC(); <END> } long currentTime = this.clock.millis(); if (currentTime > nextCheckAfter) { long intervalMins = internalCheck(c); nextCheckAfter = currentTime + TimeUnit.MINUTES.toMillis(intervalMins); return intervalMins; } else { return 1; } } finally { checkLock.unlock(); } } }</code><technical_language>This bit in readResolve() field is transient</technical_language>

Target:
public long check(EC2Computer c) { if (!checkLock.tryLock()) { return 1; } else { try { long currentTime = this.clock.millis(); if (currentTime > nextCheckAfter) { long intervalMins = internalCheck(c); nextCheckAfter = currentTime + TimeUnit.MINUTES.toMillis(intervalMins); return intervalMins; } else { return 1; } } finally { checkLock.unlock(); } } }
Source:
<code><START> public ZooKeeperHolder zooKeeperHolder(final Environment environment) throws Exception { <END> return new ZooKeeperHolder( environment.getProperty("nakadi.zookeeper.brokers"), environment.getProperty("nakadi.zookeeper.kafkaNamespace", ""), environment.getProperty("nakadi.zookeeper.exhibitor.brokers", ""), Integer.parseInt(environment.getProperty("nakadi.zookeeper.exhibitor.port", "0")) ); }</code><technical_language>Exception is here</technical_language>

Target:
public ZooKeeperHolder zooKeeperHolder(final Environment environment) throws Exception { return new ZooKeeperHolder( environment.getProperty("nakadi.zookeeper.brokers"), environment.getProperty("nakadi.zookeeper.kafkaNamespace", ""), environment.getProperty("nakadi.zookeeper.exhibitor.brokers"), Integer.parseInt(environment.getProperty("nakadi.zookeeper.exhibitor.port", "0")) ); }
Source:
<code>synchronized void release(BaseRealm realm) { String canonicalPath = realm.getPath(); ReferenceCounter referenceCounter = getRefCounter(realm.getClass(), (realm.isFrozen()) ? realm.sharedRealm.getVersionID() : OsSharedRealm.VersionID.LIVE); int refCount = referenceCounter.getThreadLocalCount(); if (refCount <= 0) { RealmLog.warn("%s has been closed already. refCount is %s", canonicalPath, refCount); return; } refCount -= 1; if (refCount == 0) { referenceCounter.clearThreadLocalCache(); realm.doClose(); if (geTotalLiveRealmGlobalRefCount() == 0) { configuration = null; <START> for (ReferenceCounter counter : refAndCountMap.values()) { <END> if (counter instanceof GlobalReferenceCounter) { BaseRealm cachedRealm = counter.getRealmInstance(); if (cachedRealm != null) { cachedRealm.close(); } } } ObjectServerFacade.getFacade(realm.getConfiguration().isSyncConfiguration()) .realmClosed(realm.getConfiguration()); } } else { referenceCounter.setThreadCount(refCount); } }</code><technical_language>tests checking this logic</technical_language>

Target:
synchronized void release(BaseRealm realm) { String canonicalPath = realm.getPath(); ReferenceCounter referenceCounter = getRefCounter(realm.getClass(), (realm.isFrozen()) ? realm.sharedRealm.getVersionID() : OsSharedRealm.VersionID.LIVE); int refCount = referenceCounter.getThreadLocalCount(); if (refCount <= 0) { RealmLog.warn("%s has been closed already. refCount is %s", canonicalPath, refCount); return; } refCount -= 1; if (refCount == 0) { referenceCounter.clearThreadLocalCache(); realm.doClose(); if (getTotalLiveRealmGlobalRefCount() == 0) { configuration = null; for (ReferenceCounter counter : refAndCountMap.values()) { if (counter instanceof GlobalReferenceCounter) { BaseRealm cachedRealm = counter.getRealmInstance(); if (cachedRealm != null) { while (!cachedRealm.isClosed()) { cachedRealm.close(); } } } } ObjectServerFacade.getFacade(realm.getConfiguration().isSyncConfiguration()).realmClosed(realm.getConfiguration()); } } else { referenceCounter.setThreadCount(refCount); } }
Source:
<code>private Pattern turnOperandIntoRegExp(Object operand) { String operandAsString = operand.toString(); StringBuilder operandAsRegExp = new StringBuilder(replaceWildCardLikeChars(operandAsString)); if (!operandAsString.startsWith("%") && operandAsString.contains("%")) { operandAsRegExp = operandAsRegExp.insert(0, "^"); } return Pattern.compile(operandAsRegExp.toString(), Pattern.CASE_INSENSITIVE); <START> } <END></code><technical_language>this missing '%xxxxxx' case? imagine a regex $ in end in case, xxxxxxy match, while yxxxxxx would. do need special cases? I guess adding ^ $ work? A examples: 'xxxxxx' /^xxxxxxx$/ match xxxxxx. '%xxxxxx' /^.*xxxxxx$/ match xxxxxx. 'xxxxxx%' /^xxxxxx.*$/ match starting xxxxxx</technical_language>

Target:
private Pattern turnOperandIntoRegExp(Object operand) { StringBuilder operandAsRegExp = new StringBuilder(replaceWildCardLikeChars(operand.toString())); operandAsRegExp.insert(0, "^").append("$"); return Pattern.compile(operandAsRegExp.toString(), Pattern.CASE_INSENSITIVE); }