auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public PutStatus put(K key, V value) throws CacheAccessException { checkKey(key); checkValue(value); XATransactionContext<K, V> currentContext = getCurrentContext(); if (currentContext.touched(key)) { V oldValue = currentContext.oldValueOf(key); currentContext.addCommand(key, new StorePutCommand<V>(oldValue, new XAValueHolder<V>(value, timeSource.getTimeMillis()))); return PutStatus.PUT; } ValueHolder<SoftLock<V>> softLockValueHolder = getSoftLockValueHolderFromUnderlyingStore(key); if (softLockValueHolder != null) { SoftLock<V> softLock = softLockValueHolder.value(); if (isInDoubt(softLock)) { currentContext.addCommand(key, new StoreEvictCommand<V>(softLock.getOldValue())); } else { currentContext.addCommand(key, new StorePutCommand<V>(softLock.getOldValue(), new XAValueHolder<V>(value, timeSource.getTimeMillis()))); } } else { currentContext.addCommand(key, new StorePutCommand<V>(null, new XAValueHolder<V>(value, timeSource.getTimeMillis()))); } return PutStatus.PUT; }

Target:
public PutStatus put(K key, V value) throws CacheAccessException { checkKey(key); checkValue(value); XATransactionContext<K, V> currentContext = getCurrentContext(); if (currentContext.touched(key)) { V oldValue = currentContext.oldValueOf(key); currentContext.addCommand(key, new StorePutCommand<V>(oldValue, new XAValueHolder<V>(value, timeSource.getTimeMillis()))); if (oldValue == null) { return PutStatus.PUT; } else { return PutStatus.UPDATE; } } ValueHolder<SoftLock<V>> softLockValueHolder = getSoftLockValueHolderFromUnderlyingStore(key); PutStatus status = PutStatus.NOOP; if (softLockValueHolder != null) { SoftLock<V> softLock = softLockValueHolder.value(); if (isInDoubt(softLock)) { currentContext.addCommand(key, new StoreEvictCommand<V>(softLock.getOldValue())); status = PutStatus.NOOP; } else { if (currentContext.addCommand(key, new StorePutCommand<V>(softLock.getOldValue(), new XAValueHolder<V>(value, timeSource.getTimeMillis())))) { status = PutStatus.UPDATE; } } } else { if (currentContext.addCommand(key, new StorePutCommand<V>(null, new XAValueHolder<V>(value, timeSource.getTimeMillis())))) { status = PutStatus.PUT; } } return status; }
Source:
private Predicate<Constructor<?>> createConstructorInaccessibleFromPackagePredicate(Package sourcePackage) { return constructor -> { int constructorModifiers = constructor.getModifiers(); return Modifier.isPrivate(constructorModifiers) || (!sourcePackage.equals(constructor.getDeclaringClass().getPackage()) && !Modifier.isPublic(constructorModifiers)); }; }

Target:
private Predicate<Constructor<?>> createConstructorInaccessibleFromPackagePredicate(Package sourcePackage) { return constructor -> Modifier.isPrivate(constructor.getModifiers()) || (!sourcePackage.equals(constructor.getDeclaringClass().getPackage()) && !Modifier.isPublic(constructor.getModifiers())); }
Source:
private boolean checkRange(final long position) { if (Guard.isMultiMapNullOrEmpty(ranges)) return true; final BulkObject blob = getBlobFromPosition(ranges, position); if (blob == null) return false; final long blobSize = blobSizes.get(blob); return blob.getOffset() <= position && position <= blob.getOffset() + blobSize - 1; }

Target:
private boolean checkRange(final long position) { if (Guard.isMultiMapNullOrEmpty(ranges)) return true; final BulkObject blob = getBlobFromPosition(ranges, position); if (blob == null) return false; final long blobSize = blobSizes.get(blob); return blob.getOffset() <= position && position < blob.getOffset() + blobSize; }
Source:
public void testMultipleContentLengthHeadersWithFolding() { EmbeddedChannel channel = new EmbeddedChannel(new HttpRequestDecoder()); String requestStr = "POST / HTTP/1.1\r\n" + "Host: example.com\r\n" + "Connection: close\r\n" + "Content-Length: 5\r\n" + "Content-Length:\r\n" + "\t6\r\n\r\n" + "123456"; assertTrue(channel.writeInbound(Unpooled.copiedBuffer(requestStr, CharsetUtil.US_ASCII))); HttpRequest request = channel.readInbound(); assertTrue(request.decoderResult().isFailure()); assertTrue(request.decoderResult().cause() instanceof IllegalArgumentException); assertFalse(channel.finish()); }

Target:
public void testMultipleContentLengthHeadersWithFolding() { String requestStr = "POST / HTTP/1.1\r\n" + "Host: example.com\r\n" + "Connection: close\r\n" + "Content-Length: 5\r\n" + "Content-Length:\r\n" + "\t6\r\n\r\n" + "123456"; testInvalidHeaders0(requestStr); }
Source:
protected VmStatic convertVm(int defaultOsId, DisplayType defaultDisplayType, Map vmInfo) { Guid vmId = Guid.createGuidFromString((String) vmInfo.get(VdsProperties.vm_guid)); VmStatic vmStatic = new VmStatic(); vmStatic.setId(vmId); vmStatic.setCreationDate(new Date()); vmStatic.setVdsGroupId(vdsManager.getVdsGroupId()); String vmNameOnHost = (String) vmInfo.get(VdsProperties.vm_name); if (StringUtils.equals(Config.<String>getValue(ConfigValues.HostedEngineVmName), vmNameOnHost)) { return importHostedEngineVM(vmInfo); } else { vmStatic.setName(String.format(EXTERNAL_VM_NAME_FORMAT, vmNameOnHost)); vmStatic.setOrigin(OriginType.EXTERNAL); } vmStatic.setNumOfSockets(VdsBrokerObjectsBuilder.parseIntVdsProperty(vmInfo.get(VdsProperties.num_of_cpus))); vmStatic.setMemSizeMb(VdsBrokerObjectsBuilder.parseIntVdsProperty(vmInfo.get(VdsProperties.mem_size_mb))); vmStatic.setSingleQxlPci(false); setOsId(vmStatic, (String) vmInfo.get(VdsProperties.guest_os), defaultOsId); setDisplayType(vmStatic, (String) vmInfo.get(VdsProperties.displayType), defaultDisplayType); log.info("Importing VM '{}' as '{}', as it is running on the on Host, but does not exist in the engine.", vmNameOnHost, vmStatic.getName()); externalVmsToAdd.add(vmStatic); return vmStatic; }

Target:
protected void convertVm(int defaultOsId, DisplayType defaultDisplayType, Map vmInfo) { Guid vmId = Guid.createGuidFromString((String) vmInfo.get(VdsProperties.vm_guid)); VmStatic vmStatic = new VmStatic(); vmStatic.setId(vmId); vmStatic.setCreationDate(new Date()); vmStatic.setVdsGroupId(vdsManager.getVdsGroupId()); String vmNameOnHost = (String) vmInfo.get(VdsProperties.vm_name); if (StringUtils.equals(Config.<String>getValue(ConfigValues.HostedEngineVmName), vmNameOnHost)) { importHostedEngineVM(vmInfo); return; } else { vmStatic.setName(String.format(EXTERNAL_VM_NAME_FORMAT, vmNameOnHost)); vmStatic.setOrigin(OriginType.EXTERNAL); } vmStatic.setNumOfSockets(VdsBrokerObjectsBuilder.parseIntVdsProperty(vmInfo.get(VdsProperties.num_of_cpus))); vmStatic.setMemSizeMb(VdsBrokerObjectsBuilder.parseIntVdsProperty(vmInfo.get(VdsProperties.mem_size_mb))); vmStatic.setSingleQxlPci(false); setOsId(vmStatic, (String) vmInfo.get(VdsProperties.guest_os), defaultOsId); setDisplayType(vmStatic, (String) vmInfo.get(VdsProperties.displayType), defaultDisplayType); log.info("Importing VM '{}' as '{}', as it is running on the on Host, but does not exist in the engine.", vmNameOnHost, vmStatic.getName()); externalVmsToAdd.add(vmStatic); }
Source:
public void updateTaskFromTaskData(TaskRepository taskRepository, ITask task, TaskData taskData) { Date oldModificationDate = task.getModificationDate(); TaskMapper mapper = (TaskMapper) getTaskMapping(taskData); mapper.applyTo(task); String key = task.getTaskKey(); if (key != null) { task.setSummary(NLS.bind("{0} [{1}]", mapper.getSummary(), key)); task.setTaskKey(task.getTaskId()); } if (taskData.isPartial()) { task.setModificationDate(oldModificationDate); } task.setAttribute("CODE_REVIEW", taskData.getRoot().getAttribute(GerritTaskSchema.getDefault().REVIEW_STATE.getKey()).getValue()); task.setAttribute("VERIFIED", taskData.getRoot().getAttribute(GerritTaskSchema.getDefault().VERIFY_STATE.getKey()).getValue()); }

Target:
public void updateTaskFromTaskData(TaskRepository taskRepository, ITask task, TaskData taskData) { Date oldModificationDate = task.getModificationDate(); TaskMapper mapper = (TaskMapper) getTaskMapping(taskData); mapper.applyTo(task); String key = task.getTaskKey(); if (key != null) { task.setSummary(NLS.bind("{0} [{1}]", mapper.getSummary(), key)); task.setTaskKey(task.getTaskId()); } if (taskData.isPartial()) { task.setModificationDate(oldModificationDate); } task.setAttribute(ReviewsCoreConstants.CODE_REVIEW, taskData.getRoot().getAttribute(GerritTaskSchema.getDefault().REVIEW_STATE.getKey()).getValue()); task.setAttribute(ReviewsCoreConstants.VERIFIED, taskData.getRoot().getAttribute(GerritTaskSchema.getDefault().VERIFY_STATE.getKey()).getValue()); }
Source:
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); isDarkTheme = applicationKvStore.getBoolean("theme", false); cameraMoveListener= () -> presenter.onCameraMove(mapBox.getCameraPosition().target); addCheckBoxCallback(); presenter.attachView(this); initRvNearbyList(); initThemePreferences(); mapView.onCreate(savedInstanceState); mapView.getMapAsync(mapBoxMap -> { this.mapBox=mapBoxMap; initViews(); presenter.setActionListeners(applicationKvStore); initNearbyFilter(); mapBoxMap.setStyle(isDarkTheme?Style.DARK:Style.OUTDOORS, style -> { UiSettings uiSettings = mapBoxMap.getUiSettings(); uiSettings.setCompassGravity(Gravity.BOTTOM | Gravity.LEFT); uiSettings.setCompassMargins(12, 0, 0, 24); uiSettings.setLogoEnabled(false); uiSettings.setAttributionEnabled(false); uiSettings.setRotateGesturesEnabled(false); NearbyParentFragment.this.isMapBoxReady=true; performMapReadyActions(); CameraPosition cameraPosition = new CameraPosition.Builder() .target(new LatLng(51.50550, -0.07520)) .zoom(ZOOM_LEVEL) .build(); mapBoxMap.setCameraPosition(cameraPosition); }); }); }

Target:
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); isDarkTheme = systemThemeUtils.isDeviceInNightMode(); cameraMoveListener= () -> presenter.onCameraMove(mapBox.getCameraPosition().target); addCheckBoxCallback(); presenter.attachView(this); initRvNearbyList(); initThemePreferences(); mapView.onCreate(savedInstanceState); mapView.getMapAsync(mapBoxMap -> { this.mapBox=mapBoxMap; initViews(); presenter.setActionListeners(applicationKvStore); initNearbyFilter(); mapBoxMap.setStyle(isDarkTheme?Style.DARK:Style.OUTDOORS, style -> { UiSettings uiSettings = mapBoxMap.getUiSettings(); uiSettings.setCompassGravity(Gravity.BOTTOM | Gravity.LEFT); uiSettings.setCompassMargins(12, 0, 0, 24); uiSettings.setLogoEnabled(true); uiSettings.setAttributionEnabled(true); uiSettings.setRotateGesturesEnabled(false); NearbyParentFragment.this.isMapBoxReady=true; performMapReadyActions(); CameraPosition cameraPosition = new CameraPosition.Builder() .target(new LatLng(51.50550, -0.07520)) .zoom(ZOOM_LEVEL) .build(); mapBoxMap.setCameraPosition(cameraPosition); }); }); }
Source:
public URLStreamHandler createURLStreamHandler(String protocol) { LOG.debug("createURLStreamHandler(" + protocol + ")"); if (fExtensionPoints != null) { ExtensionPoint ep = fExtensionPoints .get("org.apache.nutch.protocol.Protocol"); if (ep != null) { Extension[] extensions = ep.getExtensions(); for (Extension extension : extensions) { String p = extension.getAttribute("protocolName"); LOG.trace("Found " + p); if (p.equals(protocol)) { LOG.debug("suitable " + p); Object extinst = null; try { extinst = extension.getExtensionInstance(); LOG.debug("instantiated " + extinst.getClass().getName()); } catch (Exception e) { LOG.warn("Could not instantiate " + extension.getId(), e); } String handlerClass = extension.getAttribute("urlStreamHandler"); LOG.debug("urlStreamHandler=" + handlerClass); if (handlerClass != null) { ClassLoader cl = this.getClass().getClassLoader(); LOG.trace("Using nutch classloader " + cl); if (extinst != null) { cl = extinst.getClass().getClassLoader(); LOG.trace("Using extension classloader " + cl); } try { Class clazz = cl.loadClass(handlerClass); return (URLStreamHandler) clazz.newInstance(); } catch (Exception e) { LOG.error("Could not instantiate protocol " + protocol + " handler class " + handlerClass + " defined by extension " + extension.getId(), e); return null; } } LOG.debug( "suitable protocol extension found that did not declare a handler"); return null; } } LOG.debug("No suitable protocol extensions registered"); } else { LOG.debug("No protocol extensions registered?"); } } return null; }

Target:
public URLStreamHandler createURLStreamHandler(String protocol) { LOG.debug("createURLStreamHandler({})", protocol); if (fExtensionPoints != null) { ExtensionPoint ep = fExtensionPoints .get("org.apache.nutch.protocol.Protocol"); if (ep != null) { Extension[] extensions = ep.getExtensions(); for (Extension extension : extensions) { String p = extension.getAttribute("protocolName"); LOG.trace("Found {}", p); if (p.equals(protocol)) { LOG.debug("suitable {}", p); Object extinst = null; try { extinst = extension.getExtensionInstance(); LOG.debug("found {}", extinst.getClass().getName()); } catch (Exception e) { LOG.warn("Could not find {}", extension.getId(), e); } String handlerClass = extension.getAttribute("urlStreamHandler"); LOG.debug("urlStreamHandler={}", handlerClass); if (handlerClass != null) { ClassLoader cl = this.getClass().getClassLoader(); LOG.trace("Using nutch classloader {}", cl); if (extinst != null) { cl = extinst.getClass().getClassLoader(); LOG.trace("Using extension classloader {}", cl); } try { Class clazz = cl.loadClass(handlerClass); return (URLStreamHandler) clazz.newInstance(); } catch (Exception e) { LOG.error("Could not instantiate protocol handler class defined by extension {}", protocol, handlerClass, extension.getId(), e); return null; } } LOG.debug( "suitable protocol extension found that did not declare a handler"); return null; } } LOG.debug("No suitable protocol extensions registered"); } else { LOG.debug("No protocol extensions registered?"); } } return null; }
Source:
public void testParameterMD() throws SQLException { PreparedStatement pstmt = _conn.prepareStatement("SELECT a FROM parametertest WHERE b = ? AND c = ? AND d >^ ? "); ParameterMetaData pmd = pstmt.getParameterMetaData(); assertEquals(3, pmd.getParameterCount()); assertEquals(Types.DOUBLE, pmd.getParameterType(1)); assertEquals("float8", pmd.getParameterTypeName(1)); assertEquals("java.lang.Double", pmd.getParameterClassName(1)); assertEquals(Types.VARCHAR, pmd.getParameterType(2)); assertEquals("text", pmd.getParameterTypeName(2)); assertEquals("java.lang.String", pmd.getParameterClassName(2)); assertEquals(Types.BINARY, pmd.getParameterType(3)); assertEquals("point", pmd.getParameterTypeName(3)); pstmt.close(); }

Target:
public void testParameterMD() throws SQLException { PreparedStatement pstmt = _conn.prepareStatement("SELECT a FROM parametertest WHERE b = ? AND c = ? AND d >^ ? "); ParameterMetaData pmd = pstmt.getParameterMetaData(); assertEquals(3, pmd.getParameterCount()); assertEquals(Types.DOUBLE, pmd.getParameterType(1)); assertEquals("float8", pmd.getParameterTypeName(1)); assertEquals("java.lang.Double", pmd.getParameterClassName(1)); assertEquals(Types.VARCHAR, pmd.getParameterType(2)); assertEquals("text", pmd.getParameterTypeName(2)); assertEquals("java.lang.String", pmd.getParameterClassName(2)); assertEquals(Types.OTHER, pmd.getParameterType(3)); assertEquals("point", pmd.getParameterTypeName(3)); pstmt.close(); }
Source:
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain nextFilter) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletResponse response = (HttpServletResponse) servletResponse; if (authorizers.isEmpty()) { log.debug("Skipping authorization for request %s %s %s", request.getMethod(), request.getRequestURI(), request.toString()); nextFilter.doFilter(request, response); return; } log.debug("Applying authorization filter to request %s %s", request.getRequestURI(), request.toString()); for (Authorizer authorizer : authorizers) { if (!authorizer.authorize(request)) { log.warn("Authorization FAILED for request: %s %s uri: %s", request.getMethod(), request.toString(), request.getRequestURI()); response.sendError(SC_FORBIDDEN, "Not Authorized to access this resource"); return; } } nextFilter.doFilter(request, response); }

Target:
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain nextFilter) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletResponse response = (HttpServletResponse) servletResponse; if (authorizers.isEmpty()) { nextFilter.doFilter(request, response); return; } for (Authorizer authorizer : authorizers) { try { authorizer.authorize(request); } catch (AuthorizationException e) { log.warn("Authorization FAILED for request: %s %s uri: %s", request.getMethod(), request.toString(), request.getRequestURI()); response.sendError(SC_FORBIDDEN, e.getMessage() != null ? e.getMessage() : "Not Authorized to access this resource"); return; } } nextFilter.doFilter(request, response); }
Source:
public Response<Set<String>> apply(ChangeResource req, Input input) throws AuthException, OrmException, IOException, BadRequestException { if (input == null || (Strings.isNullOrEmpty(input.add) && Strings .isNullOrEmpty(input.remove))) { throw new BadRequestException("Hashtags are required"); } ChangeControl control = req.getControl(); if (!control.canEditHashtags()) { throw new AuthException("Editing hashtags not permitted"); } ChangeUpdate update = updateFactory.create(control); ChangeNotes notes = control.getNotes().load(); Set<String> oldHashtags = notes.getHashtags(); Set<String> hashtags = new HashSet<String>(); if (oldHashtags != null) { hashtags.addAll(oldHashtags); }; if (!Strings.isNullOrEmpty(input.add)) { hashtags.addAll(Lists.newArrayList(Splitter.on(CharMatcher.anyOf(",;")) .trimResults().omitEmptyStrings().split(input.add))); } if (!Strings.isNullOrEmpty(input.remove)) { hashtags.removeAll(Lists.newArrayList(Splitter .on(CharMatcher.anyOf(",;")).trimResults().omitEmptyStrings() .split(input.remove))); } update.setHashtags(hashtags); update.commit(); indexer.index(dbProvider.get(), update.getChange()); return Response.ok(hashtags); }

Target:
public Response<TreeSet<String>> apply(ChangeResource req, Input input) throws AuthException, OrmException, IOException, BadRequestException { if (input == null || (Strings.isNullOrEmpty(input.add) && Strings .isNullOrEmpty(input.remove))) { throw new BadRequestException("Hashtags are required"); } ChangeControl control = req.getControl(); if (!control.canEditHashtags()) { throw new AuthException("Editing hashtags not permitted"); } ChangeUpdate update = updateFactory.create(control); ChangeNotes notes = control.getNotes().load(); Set<String> existingHashtags = notes.getHashtags(); Set<String> updatedHashtags = new HashSet<>(); Set<String> toAdd = new HashSet<>(extractTags(input.add)); Set<String> toRemove = new HashSet<>(extractTags(input.remove)); if (existingHashtags != null && !existingHashtags.isEmpty()) { updatedHashtags.addAll(existingHashtags); toAdd.removeAll(existingHashtags); toRemove.retainAll(existingHashtags); } if (toAdd.size() > 0 || toRemove.size() > 0) { updatedHashtags.addAll(toAdd); updatedHashtags.removeAll(toRemove); update.setHashtags(updatedHashtags); update.commit(); indexer.index(dbProvider.get(), update.getChange()); } return Response.ok(new TreeSet<String>(updatedHashtags)); }
Source:
public void processAllUpdates() { horizontalGraphGroup.processAllUpdates(); verticalGraphGroup.processAllUpdates(); if (!this.positionsAffected.isEmpty()) { LongIterator itrPositions = this.positionsAffected.iterator(); while (itrPositions.hasNext()) { long pos = itrPositions.nextLong(); int oldHorizDistance = this.horizDistances.get(pos); int oldVertDistance = this.vertDistances.get(pos); int horizCurrentDistance = horizontalGraphGroup.getLevel(pos); int vertCurrentDistance = verticalGraphGroup.getLevel(pos); if (oldHorizDistance != horizCurrentDistance || oldVertDistance != vertCurrentDistance) { iTicketManager.getCubeTaskPriorityQueueSorter().onUpdateCubeLevel(CubePos.from(pos), () -> this.horizDistances.get(pos), horizCurrentDistance, (horizDistance) -> { if (horizCurrentDistance >= this.horizDistances.defaultReturnValue() || vertCurrentDistance >= this.vertDistances.defaultReturnValue()) { this.horizDistances.remove(pos); this.vertDistances.remove(pos); } else { this.horizDistances.put(pos, horizCurrentDistance); this.vertDistances.put(pos, vertCurrentDistance); } }); this.updateTicket(pos, horizCurrentDistance, this.isWithinViewDistance(oldHorizDistance, oldVertDistance), this.isWithinViewDistance(horizCurrentDistance, vertCurrentDistance)); } } this.positionsAffected.clear(); } }

Target:
public void processAllUpdates() { horizontalGraphGroup.processAllUpdates(); verticalGraphGroup.processAllUpdates(); if (!this.positionsAffected.isEmpty()) { LongIterator itrPositions = this.positionsAffected.iterator(); while (itrPositions.hasNext()) { long pos = itrPositions.nextLong(); int oldHorizDistance = this.horizDistances.get(pos); int oldVertDistance = this.vertDistances.get(pos); int horizCurrentDistance = horizontalGraphGroup.getLevel(pos); int vertCurrentDistance = verticalGraphGroup.getLevel(pos); if (oldHorizDistance != horizCurrentDistance || oldVertDistance != vertCurrentDistance) { iTicketManager.getCubeTaskPriorityQueueSorter().onUpdateCubeLevel(CubePos.from(pos), () -> this.horizDistances.get(pos), horizCurrentDistance+verticalViewDistance, (horizDistance) -> { if (horizCurrentDistance >= this.horizDistances.defaultReturnValue() || vertCurrentDistance >= this.vertDistances.defaultReturnValue()) { this.horizDistances.remove(pos); this.vertDistances.remove(pos); } else { this.horizDistances.put(pos, horizCurrentDistance); this.vertDistances.put(pos, vertCurrentDistance); } }); this.updateTicket(pos, horizCurrentDistance, this.isWithinViewDistance(oldHorizDistance, oldVertDistance), this.isWithinViewDistance(horizCurrentDistance, vertCurrentDistance)); } } this.positionsAffected.clear(); } }
Source:
private void clientCertCheck(){ int enableClientCert = getInteger(USE_CLIENT_CERT, 0); String certPath = getString(CLIENT_CERT_LOCATION, ""); String certPass = getString(CLIENT_CERT_PASSWORD, ""); if(enableClientCert!=0 && !certPath.isEmpty() && !certPass.isEmpty()) { try { SSLContextManager contextManager = getSSLContextManager(); int ksIndex = contextManager.loadPKCS12Certificate(certPath, certPass); contextManager.unlockKey(ksIndex, ksIndex, certPass); contextManager.setDefaultKey(ksIndex, ksIndex); setActiveCertificate(); setEnableCertificate(true); logger.info("Client Certificate enabled from CLI"); logger.info("Use -config certificate.persist=1 to save settings"); } catch (IOException ex) { logger.error("IO exception", ex); } catch (CertificateException ex) { logger.error("Certificate exception", ex); } catch (NoSuchAlgorithmException ex) { logger.error("NoSuchAlgorithm exception", ex); } catch (KeyStoreException ex) { logger.error("KeyStore exception", ex); } catch (KeyManagementException ex) { logger.error("KeyManagement exception", ex); } } }

Target:
private void clientCertCheck(){ boolean enableClientCert = getBoolean(USE_CLIENT_CERT, false); String certPath = getString(CLIENT_CERT_LOCATION, ""); String certPass = getString(CLIENT_CERT_PASSWORD, ""); int certIndex = getInt(CLIENT_CERT_INDEX, 0); if(enableClientCert && !certPath.isEmpty() && !certPass.isEmpty()) { try { SSLContextManager contextManager = getSSLContextManager(); int ksIndex = contextManager.loadPKCS12Certificate(certPath, certPass); contextManager.unlockKey(ksIndex, certIndex, certPass); contextManager.setDefaultKey(ksIndex, certIndex); setActiveCertificate(); setEnableCertificate(true); logger.info("Client Certificate enabled from CLI"); logger.info("Use -config certificate.persist=true to save settings"); } catch (IOException|CertificateException|NoSuchAlgorithmException|KeyStoreException|KeyManagementException ex) { logger.error("The certificate could not be enabled due to an error", ex); } } }
Source:
public int ifHit(Vector<Bullet> shipBullets) { Iterator iteralien = ConcreteAggregate.createIterator(shipBullets); while (iteralien.hasNext()) { Bullet bullet = (Bullet) iteralien.next(); if (bullet.getY() > ypos - 12 && bullet.getY() < ypos + 20) { if (bullet.getX() > xpos - 6 && bullet.getX() < xpos + 50) { Game.logfile.writeHit("Alien", xpos, ypos); health--; return iteralien.position(); } } } return -1; }

Target:
public int ifHit(Vector<Bullet> shipBullets) { Iterator iterShipBullets = ConcreteAggregate.createIterator(shipBullets); while (iterShipBullets.hasNext()) { Bullet bullet = (Bullet) iterShipBullets.next(); if (bullet.getY() > ypos - 12 && bullet.getY() < ypos + 20) { if (bullet.getX() > xpos - 6 && bullet.getX() < xpos + 50) { Game.logfile.writeHit("Alien", xpos, ypos); health--; return iterShipBullets.position(); } } } return -1; }
Source:
public void minAgeLimitButBirthdateTooRecent() { String birthdate = DateTime.now().minusYears(18).plusDays(1).toLocalDate().toString(); validator = new ConsentSignatureValidator(18); ConsentSignature sig = new ConsentSignature.Builder().withName("test name").withBirthdate(birthdate).build(); assertValidatorMessage(validator, sig, "birthdate", "too recent (the study requires participants to be 18 years of age or older)."); }

Target:
public void minAgeLimitButBirthdateTooRecent() { String birthdate = NOW.minusYears(18).plusDays(1).toLocalDate().toString(); validator = new ConsentSignatureValidator(18); ConsentSignature sig = new ConsentSignature.Builder().withName("test name").withBirthdate(birthdate).build(); assertValidatorMessage(validator, sig, "birthdate", "too recent (the study requires participants to be 18 years of age or older)."); }
Source:
public ImportEntriesDialog(BibDatabaseContext database, BackgroundTask<ParserResult> task) { this.database = database; this.task = task; ViewLoader.view(this) .load() .setAsDialogPane(this); BooleanBinding booleanBind = Bindings.isEmpty(entriesListView.getCheckModel().getCheckedItems()); Button btn = (Button) this.getDialogPane().lookupButton(importButton); btn.disableProperty().bind(booleanBind); setResultConverter(button -> { if (button == importButton) { viewModel.importEntries(entriesListView.getCheckModel().getCheckedItems(), downloadLinkedOnlineFiles.isSelected()); } else { dialogService.notify(Localization.lang("Import canceled")); } return false; }); }

Target:
public ImportEntriesDialog(BibDatabaseContext database, BackgroundTask<ParserResult> task) { this.database = database; this.task = task; ViewLoader.view(this) .load() .setAsDialogPane(this); BooleanBinding booleanBind = Bindings.isEmpty(entriesListView.getCheckModel().getCheckedItems()); Button btn = (Button) this.getDialogPane().lookupButton(importButton); btn.disableProperty().bind(booleanBind); downloadLinkedOnlineFiles.setSelected(preferences.getFilePreferences().getDownloadLinkedFiles()); setResultConverter(button -> { if (button == importButton) { viewModel.importEntries(entriesListView.getCheckModel().getCheckedItems(), downloadLinkedOnlineFiles.isSelected()); } else { dialogService.notify(Localization.lang("Import canceled")); } return false; }); }
Source:
public Subscriber<? super T> call(final Subscriber<? super T> child) { return new Subscriber<T>(child) { U previousKey; boolean hasPrevious; @Override public void onNext(T t) { U currentKey = previousKey; final U key; try { key = keySelector.call(t); } catch (Throwable e) { Exceptions.throwOrReport(e, child, t); return; } previousKey = key; if (hasPrevious) { Boolean comparison; try { comparison = comparator.call(currentKey, key); } catch (Throwable e) { Exceptions.throwOrReport(e, child, key); return; } if (!comparison) { child.onNext(t); } else { request(1); } } else { hasPrevious = true; child.onNext(t); } } @Override public void onError(Throwable e) { child.onError(e); } @Override public void onCompleted() { child.onCompleted(); } }; }

Target:
public Subscriber<? super T> call(final Subscriber<? super T> child) { return new Subscriber<T>(child) { U previousKey; boolean hasPrevious; @Override public void onNext(T t) { U currentKey = previousKey; final U key; try { key = keySelector.call(t); } catch (Throwable e) { Exceptions.throwOrReport(e, child, t); return; } previousKey = key; if (hasPrevious) { boolean comparison; try { comparison = comparator.call(currentKey, key); } catch (Throwable e) { Exceptions.throwOrReport(e, child, key); return; } if (!comparison) { child.onNext(t); } else { request(1); } } else { hasPrevious = true; child.onNext(t); } } @Override public void onError(Throwable e) { child.onError(e); } @Override public void onCompleted() { child.onCompleted(); } }; }
Source:
public static List<Schema.Field> getSchemaFields(ResultSet resultSet, @Nullable String schemaStr) throws SQLException { Schema resultsetSchema = Schema.recordOf("resultset", getSchemaFields(resultSet)); if (!Strings.isNullOrEmpty(schemaStr)) { try { Schema schema = Schema.parseJson(schemaStr); for (Schema.Field field : schema.getFields()) { Schema.Field resultsetField = resultsetSchema.getField(field.getName()); if (resultsetField == null) { throw new IllegalArgumentException(String.format("Schema field %s is not present in input record", field.getName())); } Schema resultsetFieldSchema = resultsetField.getSchema().isNullable() ? resultsetField.getSchema().getNonNullable() : resultsetField.getSchema(); Schema simpleSchema = field.getSchema().isNullable() ? field.getSchema().getNonNullable() : field.getSchema(); if (!resultsetFieldSchema.equals(simpleSchema)) { throw new IllegalArgumentException(String.format("Schema field %s has type %s but in input record found " + "type %s ", field.getName(), simpleSchema.getType(), resultsetFieldSchema.getType())); } } return schema.getFields(); } catch (IOException e) { throw new IllegalArgumentException(String.format("Can not covert schema string %s to Schema", schemaStr), e); } } return resultsetSchema.getFields(); }

Target:
public static List<Schema.Field> getSchemaFields(ResultSet resultSet, @Nullable String schemaStr) throws SQLException { Schema resultsetSchema = Schema.recordOf("resultset", getSchemaFields(resultSet)); Schema schema; if (!Strings.isNullOrEmpty(schemaStr)) { try { schema = Schema.parseJson(schemaStr); } catch (IOException e) { throw new IllegalArgumentException(String.format("Unable to parse schema string %s", schemaStr), e); } for (Schema.Field field : schema.getFields()) { Schema.Field resultsetField = resultsetSchema.getField(field.getName()); if (resultsetField == null) { throw new IllegalArgumentException(String.format("Schema field %s is not present in input record", field.getName())); } Schema resultsetFieldSchema = resultsetField.getSchema().isNullable() ? resultsetField.getSchema().getNonNullable() : resultsetField.getSchema(); Schema simpleSchema = field.getSchema().isNullable() ? field.getSchema().getNonNullable() : field.getSchema(); if (!resultsetFieldSchema.equals(simpleSchema)) { throw new IllegalArgumentException(String.format("Schema field %s has type %s but in input record found " + "type %s ", field.getName(), simpleSchema.getType(), resultsetFieldSchema.getType())); } } return schema.getFields(); } return resultsetSchema.getFields(); }
Source:
public Map<Integer, Set<Integer>> getStoreIdToBlockIds() { return null; }

Target:
public Map<Integer, Set<Integer>> getStoreIdToBlockIds() { return Collections.emptyMap(); }
Source:
public String getPagingData() { if(getPagination() == null) return ""; return getPagination().getTag(); }

Target:
public String getPagingData() { if (getPagination() == null) { return ""; } return getPagination().getTag(); }
Source:
private boolean consoleDeviceChanged() { List<VmDevice> consoleDevices = getVmDeviceDao().getVmDeviceByVmIdTypeAndDevice(getParameters().getVmId(), VmDeviceGeneralType.CONSOLE, VmDeviceType.CONSOLE.getName()); return getParameters().isConsoleEnabled() == consoleDevices.isEmpty(); }

Target:
private boolean consoleDeviceChanged() { List<VmDevice> consoleDevices = getVmDeviceDao().getVmDeviceByVmIdAndType(getParameters().getVmId(), VmDeviceGeneralType.CONSOLE); return getParameters().isConsoleEnabled() == consoleDevices.isEmpty(); }
Source:
public ServerSocket createServerSocket(String name) throws IOException { return this.factory.createServerSocket(name); }

Target:
public ServerSocket createServerSocket(String name) throws IOException { return this.register(this.factory.createServerSocket(name)); }
Source:
public boolean includes(char[] simpleName) { boolean result = sortedArrayContains(this.simpleNameReferences, simpleName, CHAR_ARR_COMPARATOR); if (REFERENCE_COLLECTION_DEBUG) { if (result != debugIncludes(simpleName)) { String message = "Mismatch: " + String.valueOf(simpleName) + (result ? " should not " : " should ") + " be included in " + Arrays.asList(CharOperation.toStrings(this.simpleNameReferences)); throw new IllegalStateException(message); } } return result; }

Target:
public boolean includes(char[] simpleName) { boolean result = sortedArrayContains(this.simpleNameReferences, simpleName, CHAR_ARR_COMPARATOR); if (REFERENCE_COLLECTION_DEBUG) { assertIncludes(result, simpleName); } return result; }
Source:
public boolean onKeyEvent(NUIKeyEvent event) { if (event.isDown() && TabbingManager.focusedWidget.equals(this)) { int keyId = event.getKey().getId(); if (keyId == Keyboard.KeyId.RIGHT || keyId == Keyboard.KeyId.UP) { this.changeValue(getIncrement()); return true; } else if (keyId == Keyboard.KeyId.LEFT || keyId == Keyboard.KeyId.DOWN) { this.changeValue(-1 * getIncrement()); return true; } } return super.onKeyEvent(event); }

Target:
public boolean onKeyEvent(NUIKeyEvent event) { if (event.isDown() && this.equals(TabbingManager.focusedWidget)) { int keyId = event.getKey().getId(); if (keyId == Keyboard.KeyId.RIGHT || keyId == Keyboard.KeyId.UP) { this.changeValue(getIncrement()); return true; } else if (keyId == Keyboard.KeyId.LEFT || keyId == Keyboard.KeyId.DOWN) { this.changeValue(-1 * getIncrement()); return true; } } return super.onKeyEvent(event); }
Source:
private Configuration getConfigurationForExportSystem(String pid) { Configuration config = mock(Configuration.class); Dictionary<String, Object> props = new Hashtable<>(); try { props.put( DirectoryWatcher.FILENAME, ddfHome.resolve("etc").toRealPath().resolve(String.format("%s.config", pid)).toUri()); } catch (IOException e) { fail("Unable to resolve configuration path"); } props.put("service.pid", pid); props.put("schema", "<LINK_0>"); if (pid.equals(METACARD_VALIDITY_FILTER_PLUGIN_PID)) { props.put("attributeMap", new String[] {"invalid-state=data-manager", "system-user"}); props.put("filterWarnings", "false"); props.put("filterErrors", "true"); } when(config.getProperties()).thenReturn(props); when(config.getPid()).thenReturn(pid); return config; }

Target:
private Configuration getConfigurationForExportSystem(String pid) { Configuration config = mock(Configuration.class); Dictionary<String, Object> props = new Hashtable<>(); try { props.put( DirectoryWatcher.FILENAME, ddfHome.resolve("etc").toRealPath().resolve(String.format("%s.config", pid)).toUri()); } catch (IOException e) { fail("Unable to resolve configuration path"); } props.put("service.pid", pid); props.put("schema", "<LINK_0>"); if (pid.equals(METACARD_VALIDITY_FILTER_PLUGIN_PID)) { props.put( "attributeMap", new String[] { "invalid-state=data-manager,system-user", "invalid-state=hostname-data-manager,system-user" }); props.put("filterWarnings", "false"); props.put("filterErrors", "true"); } when(config.getProperties()).thenReturn(props); when(config.getPid()).thenReturn(pid); return config; }
Source:
public void cleanupExpiredPools() { List<Pool> pools = poolCurator.listExpiredPools(); log.info("Expired pools: " + pools.size()); List<Pool> toDelete = new LinkedList<Pool>(); for (Pool p : pools) { if (p.hasAttribute("pool_derived")) { continue; } log.debug("Cleaning up expired pool: " + p.getId() + " (" + p.getEndDate() + ")"); toDelete.add(p); if (!subAdapter.isReadOnly()) { Subscription sub = subAdapter.getSubscription(p.getSubscriptionId()); if (sub != null) { subAdapter.deleteSubscription(sub); } } } deletePools(toDelete); }

Target:
public void cleanupExpiredPools() { List<Pool> pools = poolCurator.listExpiredPools(); log.info("Expired pools: " + pools.size()); List<Pool> toDelete = new LinkedList<Pool>(); for (Pool p : pools) { if (p.hasAttribute("pool_derived")) { continue; } log.debug("Cleaning up expired pool: ({})", p.getId(), p.getEndDate()); toDelete.add(p); if (!subAdapter.isReadOnly()) { Subscription sub = subAdapter.getSubscription(p.getSubscriptionId()); if (sub != null) { subAdapter.deleteSubscription(sub); } } } deletePools(toDelete); }
Source:
public void processElement(DoFn<Read, KV<Contig, Read>>.ProcessContext c) throws Exception { final Read read = c.element(); long pos = read.getAlignment().getPosition().getPosition(); if (lastPos > pos) { LOG.info("Out of order read at pos "+ lastPos + " " + pos); } lastPos = pos; minPos = Math.min(minPos, pos); maxPos = Math.max(maxPos, pos); count++; c.output( KV.of( shardKeyForRead(read, lociPerShard), read)); readCountAggregator.addValue(1); if (isUnmapped(read)) { unmappedReadCountAggregator.addValue(1); } }

Target:
public void processElement(DoFn<Read, KV<Contig, Read>>.ProcessContext c) throws Exception { final Read read = c.element(); long pos = read.getAlignment().getPosition().getPosition(); minPos = Math.min(minPos, pos); maxPos = Math.max(maxPos, pos); count++; c.output( KV.of( shardKeyForRead(read, lociPerShard), read)); readCountAggregator.addValue(1); if (isUnmapped(read)) { unmappedReadCountAggregator.addValue(1); } }
Source:
public LocationHierarchyLevel makePlaceHolder(String id, String name) { LocationHierarchyLevel locationHierarchyLevel = new LocationHierarchyLevel(); locationHierarchyLevel.setUuid(id); locationHierarchyLevel.setName(name); locationHierarchyLevel.setKeyIdentifier(-1); return locationHierarchyLevel; }

Target:
public LocationHierarchyLevel makePlaceHolder(String id, String name) { LocationHierarchyLevel locationHierarchyLevel = new LocationHierarchyLevel(); locationHierarchyLevel.setUuid(id); locationHierarchyLevel.setName(name); locationHierarchyLevel.setKeyIdentifier(id.hashCode()); return locationHierarchyLevel; }
Source:
public static void tryFailure(Promise<?> p, Throwable cause, InternalLogger logger) { if (!p.tryFailure(cause) && logger != null) { Throwable err = p.cause(); if (err == null) { logger.warn("Failed to mark a promise as failure because it has succeeded already: {}", p, cause); } else { if (logger.isWarnEnabled()) { logger.warn( "Failed to mark a promise as failure because it has failed already: {}, unnotified cause: {}", p, ThrowableUtil.stackTraceToString(err), cause); } } } }

Target:
public static void tryFailure(Promise<?> p, Throwable cause, InternalLogger logger) { if (!p.tryFailure(cause) && logger != null) { Throwable err = p.cause(); if (err == null) { logger.warn("Failed to mark a promise as failure because it has succeeded already: {}", p, cause); } else if (logger.isWarnEnabled()) { logger.warn( "Failed to mark a promise as failure because it has failed already: {}, unnotified cause: {}", p, ThrowableUtil.stackTraceToString(err), cause); } } }
Source:
public List<permissions> getAllForEntity(Guid id, Guid userID, boolean isFiltered) { Integer appMode = Config.<Integer> GetValue(ConfigValues.ApplicationMode); MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() .addValue("id", id).addValue("user_id", userID).addValue("is_filtered", isFiltered) .addValue("app_mode", appMode.intValue()); return getCallsHandler().executeReadList("GetPermissionsByEntityId", PermissionRowMapper.instance, parameterSource); }

Target:
public List<permissions> getAllForEntity(Guid id, Guid userID, boolean isFiltered) { int appMode = Config.<Integer> GetValue(ConfigValues.ApplicationMode); MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() .addValue("id", id).addValue("user_id", userID).addValue("is_filtered", isFiltered) .addValue("app_mode", appMode); return getCallsHandler().executeReadList("GetPermissionsByEntityId", PermissionRowMapper.instance, parameterSource); }
Source:
private void executeBuild(List<String> arguments, ProjectConnection connection, String[] tasks) { List<String> args = Lists.newArrayListWithCapacity(2 + arguments.size()); args.add("-i"); args.add("-u"); args.addAll(arguments); BuildLauncher launcher = connection.newBuild().forTasks(tasks) .withArguments(args.toArray(new String[args.size()])); StringBuilder jvmArguments = new StringBuilder(); String debugIntegrationTest = System.getenv("DEBUG_INNER_TEST"); if (!Strings.isNullOrEmpty(debugIntegrationTest) && debugIntegrationTest.equals(name)) { jvmArguments.append("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"); } if (JacocoAgent.isJacocoEnabled()) { if (jvmArguments.length() != 0) { jvmArguments.append(' '); } jvmArguments.append(JacocoAgent.getJvmArg()); } if (jvmArguments.length() > 0) { launcher.setJvmArguments(jvmArguments.toString()); } if (stdout != null) { launcher.setStandardOutput(stdout); } launcher.run(); }

Target:
private void executeBuild(List<String> arguments, ProjectConnection connection, String[] tasks) { List<String> args = Lists.newArrayListWithCapacity(2 + arguments.size()); args.add("-i"); args.add("-u"); args.addAll(arguments); BuildLauncher launcher = connection.newBuild().forTasks(tasks) .withArguments(args.toArray(new String[args.size()])); List<String> jvmArguments = new ArrayList<String>(); String debugIntegrationTest = System.getenv("DEBUG_INNER_TEST"); if (!Strings.isNullOrEmpty(debugIntegrationTest) && debugIntegrationTest.equals(name)) { jvmArguments.add("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"); } if (JacocoAgent.isJacocoEnabled()) { jvmArguments.add(JacocoAgent.getJvmArg()); } if (!jvmArguments.isEmpty()) { launcher.setJvmArguments(jvmArguments.toArray(new String[jvmArguments.size()])); } if (stdout != null) { launcher.setStandardOutput(stdout); } launcher.run(); }
Source:
public String validateJdkRootDirectory(String jdkRootDirectory) { if( jdkRootDirectory == null || jdkRootDirectory.isEmpty()) { return Messages.NoJdkDirectoryFoundMsg; } File directory = new File(jdkRootDirectory); if (!directory.exists() || !directory.isDirectory()) { return Messages.directoryNotExistMsg; } File toolsJarFile = new File(jdkRootDirectory + TOOLS_JAR); if (!toolsJarFile.exists()) { return Messages.notJdkRootDirectoryMsg; } String libraryPath = getJreLibraryPath(jdkRootDirectory); if (libraryPath == null) { return Messages.notJdkRootDirectoryMsg; } return null; }

Target:
public String validateJdkRootDirectory(String jdkRootDirectory) { if( jdkRootDirectory == null || jdkRootDirectory.trim().isEmpty()) { return Messages.NoJdkDirectoryFoundMsg; } File directory = new File(jdkRootDirectory); if (!directory.exists() || !directory.isDirectory()) { return Messages.directoryNotExistMsg; } File toolsJarFile = new File(jdkRootDirectory + TOOLS_JAR); if (!toolsJarFile.exists()) { return Messages.notJdkRootDirectoryMsg; } String libraryPath = getJreLibraryPath(jdkRootDirectory); if (libraryPath == null) { return Messages.notJdkRootDirectoryMsg; } return null; }
Source:
private FilterExpression buildIsEmptyOperator(Path path, List<String> arguments) { String arg = arguments.get(0); try { boolean wantsEmpty = CoerceUtil.coerce(arg, boolean.class); if (wantsEmpty) { return new IsEmptyPredicate(path); } return new NotEmptyPredicate(path); } catch (InvalidValueException ignored) { throw new RSQLParseException(String.format("Invalid value for operator =isnull= '%s'", arg)); } }

Target:
private FilterExpression buildIsEmptyOperator(Path path, List<String> arguments) { String arg = arguments.get(0); try { boolean wantsEmpty = CoerceUtil.coerce(arg, boolean.class); if (wantsEmpty) { return new IsEmptyPredicate(path); } return new NotEmptyPredicate(path); } catch (InvalidValueException ignored) { throw new RSQLParseException(String.format("Invalid value for operator =isempty= '%s'", arg)); } }
Source:
public void handleException(Exception e, HttpServletResponse response, HttpServletRequest request) throws IOException { storeException(request, response, e); ResponseStatus responseStatus = getAncestors(e.getClass()) .stream() .filter(clazz -> clazz.getAnnotation(ResponseStatus.class) != null) .map(clazz -> clazz.getAnnotation(ResponseStatus.class)) .findFirst() .orElse(null); if (responseStatus != null) { logger.error(responseStatus.value().getReasonPhrase(), e); String message = e.getMessage(); if (message == null || message.trim().isEmpty()) { message = responseStatus.reason(); } response.sendError(responseStatus.value().value(), message); } else { logger.error("Internal Server Error", e); response.sendError(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage()); } }

Target:
public void handleException(Exception e, HttpServletResponse response, HttpServletRequest request) throws IOException { storeException(request, response, e); ResponseStatus responseStatus = AnnotationUtils.findAnnotation(e.getClass(), ResponseStatus.class); if (responseStatus != null) { HttpStatus httpStatus = responseStatus.value(); logger.error(httpStatus.getReasonPhrase(), e); String message = e.getMessage(); if (message == null || message.trim().isEmpty()) { message = responseStatus.reason(); } response.sendError(httpStatus.value(), message); } else { logger.error("Internal Server Error", e); response.sendError(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage()); } }
Source:
private void publishError( BoltResponseMessageHandler<IOException> out, Neo4jError error ) { try { if ( error.isFatal() ) { out.onFatal( error.status(), error.message() ); } else { out.onFailure( error.status(), error.message() ); } } catch ( PackOutputClosedException e ) { if ( error.status() == Status.Transaction.Terminated ) { log.warn( "Client %s disconnected while query was running. Session has been cleaned up. " + "This can be caused by temporary network problems, but if you see this often, " + "ensure your applications are properly waiting for operations to complete before exiting.", e.clientAddress() ); return; } log.warn( "Unable to send error back to the client. " + e.getMessage(), error.cause() ); } catch ( Throwable t ) { t.addSuppressed( error.cause() ); log.error( "Unable to send error back to the client", t ); } }

Target:
private void publishError( BoltResponseMessageHandler<IOException> out, Neo4jError error ) { try { if ( error.isFatal() ) { out.onFatal( error.status(), error.message() ); } else { out.onFailure( error.status(), error.message() ); } } catch ( PackOutputClosedException e ) { if ( CLIENT_MID_OP_DISCONNECT_ERRORS.contains( error.status() ) ) { log.warn( "Client %s disconnected while query was running. Session has been cleaned up. " + "This can be caused by temporary network problems, but if you see this often, " + "ensure your applications are properly waiting for operations to complete before exiting.", e.clientAddress() ); return; } log.warn( "Unable to send error back to the client. " + e.getMessage(), error.cause() ); } catch ( Throwable t ) { t.addSuppressed( error.cause() ); log.error( "Unable to send error back to the client", t ); } }
Source:
public void testHttpEchoServer() throws Throwable { final Lifecycle lifecycle = new Lifecycle(); try { final HttpClientConfig config = HttpClientConfig.builder().build(); final HttpClient client = HttpClientInit.createClient(config, lifecycle); final ListenableFuture<StatusResponseHolder> response = client .go( new Request(HttpMethod.GET, new URL(StringUtils.format("http://localhost:%d/", echoServerSocket.getLocalPort()))), new StatusResponseHandler(StandardCharsets.UTF_8) ); Throwable e = null; try { response.get(); } catch (ExecutionException e1) { e = e1.getCause(); } Assert.assertTrue("ChannelException thrown by 'get'", e instanceof ChannelException); Assert.assertEquals("Expected error message", "Channel disconnected", e.getMessage()); } finally { lifecycle.stop(); } }

Target:
public void testHttpEchoServer() throws Throwable { final Lifecycle lifecycle = new Lifecycle(); try { final HttpClientConfig config = HttpClientConfig.builder().build(); final HttpClient client = HttpClientInit.createClient(config, lifecycle); final ListenableFuture<StatusResponseHolder> response = client .go( new Request(HttpMethod.GET, new URL(StringUtils.format("http://localhost:%d/", echoServerSocket.getLocalPort()))), new StatusResponseHandler(StandardCharsets.UTF_8) ); expectedException.expect(ExecutionException.class); expectedException.expectMessage("java.lang.IllegalArgumentException: invalid version format: GET"); response.get(); } finally { lifecycle.stop(); } }