auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testLuceneWildcardsAreEscaped() { QueryFactory qf = getQueryFactory(); Query q = qf.from(getModelFactory().getUserImplClass()) .having("name").like("J%n").toBuilder() .build(); assertEquals(1, q.list().size()); <START> q = qf.from(getModelFactory().getUserImplClass()) <END> .having("name").like("J*n").toBuilder() .build(); q = qf.from(getModelFactory().getUserImplClass()) .having("name").like("Jo_n").toBuilder() .build(); assertEquals(1, q.list().size()); q = qf.from(getModelFactory().getUserImplClass()) .having("name").like("Jo?n").toBuilder() .build(); assertEquals(0, q.list().size()); }</code><technical_language>creating this query</technical_language>

Target:
public void testLuceneWildcardsAreEscaped() { QueryFactory qf = getQueryFactory(); Query q1 = qf.from(getModelFactory().getUserImplClass()) .having("name").like("J%n").toBuilder() .build(); assertEquals(1, q1.list().size()); Query q2 = qf.from(getModelFactory().getUserImplClass()) .having("name").like("J*n").toBuilder() .build(); assertEquals(0, q2.list().size()); Query q3 = qf.from(getModelFactory().getUserImplClass()) .having("name").like("Jo_n").toBuilder() .build(); assertEquals(1, q3.list().size()); Query q4 = qf.from(getModelFactory().getUserImplClass()) .having("name").like("Jo?n").toBuilder() .build(); assertEquals(0, q4.list().size()); }
Source:
<code>private final void endAssociation(int xaState, int txInfoState) throws XAException { <START> if (_doEnd && _theTransaction != null) { <END> _theTransaction.endAssociation(_tranID, _theXAResource, xaState, txInfoState); } }</code><technical_language>_doEnd unused variable (ie remove it)</technical_language>

Target:
private final void endAssociation(int xaState, int txInfoState) throws XAException { if (_theTransaction != null) { _theTransaction.endAssociation(_tranID, _theXAResource, xaState, txInfoState); } }
Source:
<code>public void selectAllImages() <START> { <END> for(ImageItem imageItem : localImageList) { imageItem.isSelected = true; deletableList.add(imageItem.path); } notifyDataSetChanged(); }</code><technical_language>Move brace in line of function</technical_language>

Target:
public void selectAllImages() { for(ImageItem imageItem : localImageList) { if(!deletableList.contains(imageItem.path)) { imageItem.isSelected = true; deletableList.add(imageItem.path); } } notifyDataSetChanged(); }
Source:
<code>private List<HttpCookie> processCookieHeader(String headerKey, List<String> headerValues) { List<HttpCookie> foundCookies = new LinkedList<>(); for (String headerValue : headerValues) { foundCookies <START> .addAll(HttpCookie.parse(headerKey <END> + ':' + headerValue)); } return foundCookies; }</code><technical_language>This implements older RFC 2965. _not_ remove a leading '.' domain, <LINK_0> This is crucial, RFC 6265 domain matching. a result a cookie received domain ".a.org" match hostname "b.a.org"</technical_language>

Target:
private List<HttpCookie> processCookieHeader(String headerKey, List<String> headerValues) { List<HttpCookie> foundCookies = new LinkedList<>(); for (String headerValue : headerValues) { foundCookies .addAll(HttpCookie.parse(headerKey + ':' + headerValue)); } for (HttpCookie foundCookie : foundCookies) { String domain = foundCookie.getDomain(); if (domain != null && domain.startsWith(".")) { foundCookie.setDomain(domain.substring(1)); } } return foundCookies; }
Source:
<code>private Person[] createModel() { Person[] elements = new Person[4]; elements[0] = new Person("Tom", "Schindl", "tom.schindl@bestsolution.at", "M"); elements[1] = new Person("Boris", "Bokowski", "Boris_Bokowski@ca.ibm.com", "M"); elements[2] = new Person("Tod", "Creasey", "Tod_Creasey@ca.ibm.com", "M"); <START> elements[3] = new Person("Wayne", "Beaton", "wayne@eclipse.org", "M"); <END> return elements; }</code><technical_language>add Hendrik, myself? :-)</technical_language>

Target:
private Person[] createModel() { return new Person[] { new Person("Tom", "Schindl", "tom.schindl@bestsolution.at", "M"), new Person("Boris", "Bokowski", "Boris_Bokowski@ca.ibm.com", "M"), new Person("Tod", "Creasey", "Tod_Creasey@ca.ibm.com", "M"), new Person("Wayne", "Beaton", "wayne@eclipse.org", "M"), new Person("Jeanderson", "Candido", "jeandersonbc@gmail.com", "M"), new Person("Lars", "Vogel", "lars.vogel@gmail.com", "M"), new Person("Hendrik", "Still", "hendrik.still@vogella.com", "M") }; }
Source:
<code>private <T extends RMEvent> long findLargestCounter(Collection<T> events) { final Optional<T> max = events.stream().max(Comparator.comparing(RMEvent::getCounter)); <START> return max.map(RMEvent::getCounter).orElse(0l); <END> }</code><technical_language>is case 0l about? define a constant for it? EMPTY_STATE instead (-1)</technical_language>

Target:
private <T extends RMEvent> long findLargestCounter(Collection<T> events) { final Optional<T> max = events.stream().max(Comparator.comparing(RMEvent::getCounter)); return max.map(RMEvent::getCounter).orElse(EMPTY_STATE); }
Source:
<code>public synchronized void timeUpdated(final TmfTimeSynchSignal signal) { final ITmfTimestamp ts = signal.getCurrentTime(); if (ts.intersects(getCurrentValidTimerange())) { TmfTraceContext prevCtx = getCurrentTraceContext(); TmfTraceContext newCtx = new TmfTraceContext(prevCtx, ts); <START> fTraces.put(fCurrentTrace, newCtx); <END> } }</code><technical_language>In previous implementation, a behaviour: open traces updated in case current time intersect new range</technical_language>

Target:
public synchronized void timeUpdated(final TmfTimeSynchSignal signal) { final ITmfTimestamp ts = signal.getCurrentTime(); for (Map.Entry<ITmfTrace, TmfTraceContext> entry : fTraces.entrySet()) { final ITmfTrace trace = entry.getKey(); if (ts.intersects(getCurrentTimeRange(trace))) { TmfTraceContext prevCtx = entry.getValue(); TmfTraceContext newCtx = new TmfTraceContext(prevCtx, ts); entry.setValue(newCtx); } } }
Source:
<code>public static void setUpLocale() throws Exception { Locale.setDefault(Locale.US); <START> } <END></code><technical_language>I pass Locale.US methods require instead of making global default. way, other tests expect a default locale fail</technical_language>

Target:
public void setUpLocale() throws Exception { backupLocale = Locale.getDefault(); Locale.setDefault(Locale.ROOT); }
Source:
<code>private static ContentValues toContentValues(ObaRegion region) { ContentValues values = new ContentValues(); values.put(ObaContract.Regions._ID, region.getId()); values.put(ObaContract.Regions.NAME, region.getName()); String obaUrl = region.getObaBaseUrl(); values.put(ObaContract.Regions.OBA_BASE_URL, obaUrl != null ? obaUrl : ""); String siriUrl = region.getSiriBaseUrl(); values.put(ObaContract.Regions.SIRI_BASE_URL, siriUrl != null ? siriUrl : ""); values.put(ObaContract.Regions.LANGUAGE, region.getLanguage()); values.put(ObaContract.Regions.CONTACT_EMAIL, region.getContactEmail()); values.put(ObaContract.Regions.SUPPORTS_OBA_DISCOVERY, region.getSupportsObaDiscoveryApis() ? 1 : 0); values.put(ObaContract.Regions.SUPPORTS_OBA_REALTIME, region.getSupportsObaRealtimeApis() ? 1 : 0); values.put(ObaContract.Regions.SUPPORTS_SIRI_REALTIME, region.getSupportsSiriRealtimeApis() ? 1 : 0); <START> values.put(ObaContract.Regions.SUPPORTS_EMBEDDED_SOCIAL, <END> region.getSupportsEmbeddedSocial() ? 1 : 0); values.put(ObaContract.Regions.TWITTER_URL, region.getTwitterUrl()); values.put(ObaContract.Regions.EXPERIMENTAL, region.getExperimental()); values.put(ObaContract.Regions.STOP_INFO_URL, region.getStopInfoUrl()); values.put(ObaContract.Regions.OTP_BASE_URL, region.getOtpBaseUrl()); values.put(ObaContract.Regions.OTP_CONTACT_EMAIL, region.getOtpContactEmail()); return values; }</code><technical_language>I Embedded Social moved line here, added database field</technical_language>

Target:
private static ContentValues toContentValues(ObaRegion region) { ContentValues values = new ContentValues(); values.put(ObaContract.Regions._ID, region.getId()); values.put(ObaContract.Regions.NAME, region.getName()); String obaUrl = region.getObaBaseUrl(); values.put(ObaContract.Regions.OBA_BASE_URL, obaUrl != null ? obaUrl : ""); String siriUrl = region.getSiriBaseUrl(); values.put(ObaContract.Regions.SIRI_BASE_URL, siriUrl != null ? siriUrl : ""); values.put(ObaContract.Regions.LANGUAGE, region.getLanguage()); values.put(ObaContract.Regions.CONTACT_EMAIL, region.getContactEmail()); values.put(ObaContract.Regions.SUPPORTS_OBA_DISCOVERY, region.getSupportsObaDiscoveryApis() ? 1 : 0); values.put(ObaContract.Regions.SUPPORTS_OBA_REALTIME, region.getSupportsObaRealtimeApis() ? 1 : 0); values.put(ObaContract.Regions.SUPPORTS_SIRI_REALTIME, region.getSupportsSiriRealtimeApis() ? 1 : 0); values.put(ObaContract.Regions.TWITTER_URL, region.getTwitterUrl()); values.put(ObaContract.Regions.EXPERIMENTAL, region.getExperimental()); values.put(ObaContract.Regions.STOP_INFO_URL, region.getStopInfoUrl()); values.put(ObaContract.Regions.OTP_BASE_URL, region.getOtpBaseUrl()); values.put(ObaContract.Regions.OTP_CONTACT_EMAIL, region.getOtpContactEmail()); values.put(ObaContract.Regions.SUPPORTS_OTP_BIKESHARE, region.getSupportsOtpBikeshare() ? 1 : 0); values.put(ObaContract.Regions.SUPPORTS_EMBEDDED_SOCIAL, region.getSupportsEmbeddedSocial() ? 1 : 0); return values; }
Source:
<code>private void putAllCookiesInASingleHeader(String host, CookieSpec matcher, Cookie[] cookies) { <START> LOG.trace("enter putAllCookiesInASingleHeader(HttpState state, HttpConnection conn, Cookie[] cookies)" ); <END> HashMap<String, Cookie> mergedCookies = new HashMap<String, Cookie>(); Header[] cookieLineHeaders = getRequestHeaderGroup().getHeaders(HttpHeader.COOKIE); for (Header cookieLineHeader : cookieLineHeaders) { List<Cookie> cookiesHeader = parseCookieHeader(host, cookieLineHeader.getValue()); for (Cookie cookieHeader: cookiesHeader){ mergedCookies.put(cookieHeader.getName(),cookieHeader); } getRequestHeaderGroup().removeHeader(cookieLineHeader); } for (Cookie cookie : cookies) { mergedCookies.put(cookie.getName(),cookie); } cookies = mergedCookies.values().toArray(new Cookie[mergedCookies.size()]); String s = matcher.formatCookies(cookies); getRequestHeaderGroup() .addHeader(new Header(HttpHeader.COOKIE, s, true)); }</code><technical_language>This updated match new parameters</technical_language>

Target:
private void putAllCookiesInASingleHeader(String host, CookieSpec matcher, Cookie[] cookies) { LOG.trace("enter putAllCookiesInASingleHeader(String host, CookieSpec matcher, Cookie[] cookies)" ); HashMap<String, Cookie> mergedCookies = new HashMap<String, Cookie>(); Header[] cookieLineHeaders = getRequestHeaderGroup().getHeaders(HttpHeader.COOKIE); for (Header cookieLineHeader : cookieLineHeaders) { List<Cookie> cookiesHeader = parseCookieHeader(host, cookieLineHeader.getValue()); for (Cookie cookieHeader: cookiesHeader){ mergedCookies.put(cookieHeader.getName(),cookieHeader); } getRequestHeaderGroup().removeHeader(cookieLineHeader); } for (Cookie cookie : cookies) { mergedCookies.put(cookie.getName(),cookie); } cookies = mergedCookies.values().toArray(new Cookie[mergedCookies.size()]); String s = matcher.formatCookies(cookies); getRequestHeaderGroup() .addHeader(new Header(HttpHeader.COOKIE, s, true)); }
Source:
<code><START> public Integer getCreditsDistribution() { <END> Thesis thesis = getThesis(); if (!thesis.hasCredits()) { return 0; } ThesisParticipationType type = this.getType(); if (type.equals(ThesisParticipationType.ORIENTATOR)) { if (thesis.getOrientatorCreditsDistribution() != null) { return thesis.getOrientatorCreditsDistribution(); } } if (type.equals(ThesisParticipationType.COORIENTATOR)) { if (thesis.getCoorientatorCreditsDistribution() != null) { return thesis.getCoorientatorCreditsDistribution(); } } return 0; }</code><technical_language>type change Integer breaks API</technical_language>

Target:
public double getCreditsDistribution() { Thesis thesis = getThesis(); if (!thesis.hasCredits()) { return 0; } return getPercentageDistribution(); }
Source:
<code>static void showBannerIfStartedOrExit( AbstractApplicationContext context ) { checkState( context.isRunning(), "Application context is not running." ); checkState( context.isActive(), "Application context is not active." ); <START> checkState( startupRequirementsSatisfied( context ), "Startup requiremetns have not been met." ); <END> showBanner(); }</code><technical_language>typo requirements</technical_language>

Target:
static void showBannerIfStartedOrExit( AbstractApplicationContext context ) { checkState( context.isRunning(), "Application context is not running." ); checkState( context.isActive(), "Application context is not active." ); checkState( startupRequirementsSatisfied( context ), "Startup requirements have not been met." ); showBanner(); }
Source:
<code>private void consume() { try { if (state.getType() == LogReplicationRuntimeStateType.STOPPED) { log.info("Log Replication Communication State Machine has been stopped. No more events will be processed."); return; } <START> LogReplicationRuntimeEvent event = eventQueue.take(); <END> try { LogReplicationRuntimeState newState = state.processEvent(event); transition(state, newState); state = newState; } catch (IllegalTransitionException illegalState) { log.error("Illegal log replication event when in state {}", event.getType(), state.getType()); } communicationFSMConsumer.submit(this::consume); } catch (Throwable t) { log.error("Error on event consumer: ", t); } }</code><technical_language>is a starving case standbys, standby1 call consume, standby1's eventQueue is empty, thread is blocking standby2's eventQue is empty</technical_language>

Target:
private void consume() { try { if (state.getType() == LogReplicationRuntimeStateType.STOPPED) { log.info("Log Replication Communication State Machine has been stopped. No more events will be processed."); return; } LogReplicationRuntimeEvent event = eventQueue.take(); try { LogReplicationRuntimeState newState = state.processEvent(event); if (newState != null) { transition(state, newState); state = newState; } } catch (IllegalTransitionException illegalState) { log.error("Illegal log replication event when in state {}", event.getType(), state.getType()); } communicationFSMConsumer.submit(this::consume); } catch (Throwable t) { log.error("Error on event consumer: ", t); } }
Source:
<code>public IManageablePage getPage(IPageContext context, int id) { <START> IManageablePage page = super.getPage(context, id); <END> if (page != null) { if (page instanceof SerializedPage == false) { throw new WicketRuntimeException("CryptingPageStore expects serialized pages"); } SerializedPage serializedPage = (SerializedPage)page; byte[] encrypted = serializedPage.getData(); byte[] decrypted = getSessionData(context).decrypt(encrypted); page = new SerializedPage(page.getPageId(), serializedPage.getPageType(), decrypted); } return page; }</code><technical_language>Is this getDelegate().getPage(context, id) ? getDelegate() is super</technical_language>

Target:
public IManageablePage getPage(IPageContext context, int id) { IManageablePage page = getDelegate().getPage(context, id); if (page != null) { if (page instanceof SerializedPage == false) { throw new WicketRuntimeException("CryptingPageStore expects serialized pages"); } SerializedPage serializedPage = (SerializedPage)page; byte[] encrypted = serializedPage.getData(); byte[] decrypted = getSessionData(context).decrypt(encrypted); page = new SerializedPage(page.getPageId(), serializedPage.getPageType(), decrypted); } return page; }
Source:
<code>private void applyFirstTimeChanges(ServletContext ctx, String modelPath, String modelUri, OntModel userModel) { <START> log.info("Start with check: Reload firsttime files on start-up if changed"); <END> boolean updatedFiles = false; OntModel baseModelFirsttimeBackup = ModelAccess.on(ctx).getOntModel(modelUri + "Firsttime"); log.debug("compare firsttime files with configuration models (backup from first start) for " + modelPath); OntModel baseModelFirsttime = VitroModelFactory.createOntologyModel(); RDFFilesLoader.loadFirstTimeFiles(ctx, modelPath, baseModelFirsttime, true); if (baseModelFirsttime.isIsomorphicWith(baseModelFirsttimeBackup)) { log.debug("They are the same, so do nothing"); } else { log.debug("they differ, compare values in configuration models with user's triplestore"); updatedFiles = applyChanges(baseModelFirsttimeBackup, baseModelFirsttime, userModel, modelPath); if (updatedFiles) log.info("The model was updated, " + modelPath); } }</code><technical_language>please change logging message follows: log.info("Reload firsttime files start-up if changed: '" + modelPath +"', URI: '" +modelUri+ "'");</technical_language>

Target:
private void applyFirstTimeChanges(ServletContext ctx, String modelPath, String modelUri, OntModel userModel) { log.info("Reload firsttime files on start-up if changed: '" + modelPath +"', URI: '" + modelUri + "'"); boolean updatedFiles = false; OntModel baseModelFirsttimeBackup = ModelAccess.on(ctx).getOntModel(modelUri + "FirsttimeBackup"); log.debug("compare firsttime files with configuration models (backup from first start) for " + modelPath); OntModel baseModelFirsttime = VitroModelFactory.createOntologyModel(); RDFFilesLoader.loadFirstTimeFiles(ctx, modelPath, baseModelFirsttime, true); if (baseModelFirsttime.isIsomorphicWith(baseModelFirsttimeBackup)) { log.debug("They are the same, so do nothing: '" + modelPath + "'"); } else { log.debug("They differ:" + modelPath + ", compare values in configuration models with user's triplestore"); updatedFiles = applyChanges(baseModelFirsttimeBackup, baseModelFirsttime, userModel, modelPath); if (updatedFiles) log.info("The model was updated, " + modelPath); } }
Source:
<code>public boolean compareCannonicalValues(String s1, String s2) { <START> return delegate.compareCannonicalValues(Strings.emptyToNull(s1), Strings.emptyToNull(s2)); <END> }</code><technical_language>this trigger NPE OffheapIncrementalIndex</technical_language>

Target:
public boolean compareCannonicalValues(String s1, String s2) { return delegate.compareCannonicalValues(Strings.nullToEmpty(s1), Strings.nullToEmpty(s2)); }
Source:
<code>private void analyzeVars(K term) { new VisitKORE() { @Override public Void apply(KApply k) { if (cfg.isParentCell(k.klabel())) { KVariable var = null; List<K> items = new ArrayList<>(k.klist().size()); for (K item : k.klist().items()) { if (item instanceof KVariable) { if (var != null) { <START> throw new UnsupportedOperationException( <END> "AC matching of multiple cell variables not yet supported. " + "encountered variables " + var.toString() + " and " + item.toString() + " in cell " + k); } else { var = (KVariable) item; } } else { items.add(item); } } if (var != null) { if (!variables.containsKey(var)) { variables.put(var, new VarInfo()); } variables.get(var).addOccurances(cfg, k.klabel(), var, items); } } return super.apply(k); } }.apply(term); }</code><technical_language>pointing out, needs addressed entire diff</technical_language>

Target:
private void analyzeVars(K term) { new VisitKORE() { @Override public Void apply(KApply k) { if (cfg.isParentCell(k.klabel())) { KVariable var = null; List<K> items = new ArrayList<>(k.klist().size()); for (K item : k.klist().items()) { if (item instanceof KVariable) { if (var != null) { throw KExceptionManager.criticalError( "AC matching of multiple cell variables not yet supported. " + "encountered variables " + var.toString() + " and " + item.toString() + " in cell " + k); } else { var = (KVariable) item; } } else { items.add(item); } } if (var != null) { if (!variables.containsKey(var)) { variables.put(var, new VarInfo()); } variables.get(var).addOccurances(cfg, k.klabel(), var, items); } } return super.apply(k); } }.apply(term); }
Source:
<code>public void trailingWhitespaceIsIgnored() { BlockStmt blockStmt = JavaParser.parseBlock("{} <START> assertEquals("\"}\" <95> (line 1,col 2)-(line 1,col 2)", blockStmt.getTokenRange().get().getEnd().toString()); <END> }</code><technical_language>this "95" represents here</technical_language>

Target:
public void trailingWhitespaceIsIgnored() { BlockStmt blockStmt = JavaParser.parseBlock("{} assertEquals("{}", blockStmt.getTokenRange().get().toString()); }
Source:
<code><START> public BugzillaRestRepositoryConnectorUi() { <END> connector = BugzillaRestConnector.getDefault() == null ? new BugzillaRestConnector() : BugzillaRestConnector.getDefault(); }</code><technical_language>default constructor assign "null" connector</technical_language>

Target:
public BugzillaRestRepositoryConnectorUi() { this.connector = BugzillaRestConnector.getDefault() == null ? new BugzillaRestConnector() : BugzillaRestConnector.getDefault(); }
Source:
<code>public void update(final String path, final byte[] bytes) { synchronized (toAnnounce) { if (!started) { toUpdate.add(new Announceable(path, bytes, false)); return; } } byte[] oldBytes = announcements.get(path); if (oldBytes == null) { throw new ISE("Cannot update a path[%s] that hasn't been announced!", path); } synchronized (toAnnounce) { try { if (!Arrays.equals(oldBytes, bytes)) { announcements.put(path, bytes); updateAnnouncement(path, bytes); } } catch (Exception e) { <START> throw Throwables.propagate(e); <END> } } }</code><technical_language>Throwables.propagate() in new code</technical_language>

Target:
public void update(final String path, final byte[] bytes) { synchronized (toAnnounce) { if (!started) { toUpdate.add(new Announceable(path, bytes, false)); return; } } byte[] oldBytes = announcedPaths.get(path); if (oldBytes == null) { throw new ISE("Cannot update a path[%s] that hasn't been announced!", path); } synchronized (toAnnounce) { try { if (!Arrays.equals(oldBytes, bytes)) { announcedPaths.put(path, bytes); updateAnnouncement(path, bytes); } } catch (Exception e) { throw new RuntimeException(e); } } }
Source:
<code>public boolean hasExpired() { <START> return expired; <END> }</code><technical_language>this is of expired, be: return false;</technical_language>

Target:
public boolean hasExpired() { return false; }
Source:
<code>public Tags getBucketTags(GetBucketTagsArgs args) throws ErrorResponseException, IllegalArgumentException, InsufficientDataException, InternalException, InvalidBucketNameException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, XmlParserException { if (args == null) { throw new IllegalArgumentException("null arguments"); } Map<String, String> queryParamMap = new HashMap<>(); queryParamMap.put("tagging", ""); <START> try { Response response = executeGet(args.bucket(), null, null, queryParamMap); try (ResponseBody body = response.body()) { return Xml.unmarshal(Tags.class, body.charStream()); } <END> } catch (ErrorResponseException e) { if (e.errorResponse().errorCode() != ErrorCode.NO_SUCH_TAG_SET) { throw e; } } return new Tags(); }</code><technical_language>try block response variable avoided like: suggestion try (ResponseBody body = executeGet(args.bucket(), null, null, queryParamMap).body()) { return Xml.unmarshal(Tags.class, body.charStream());</technical_language>

Target:
public Tags getBucketTags(GetBucketTagsArgs args) throws ErrorResponseException, IllegalArgumentException, InsufficientDataException, InternalException, InvalidBucketNameException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, XmlParserException { checkArgs(args); Map<String, String> queryParamMap = new HashMap<>(); queryParamMap.put("tagging", ""); try (Response response = executeGet(args.bucket(), null, null, queryParamMap)) { return Xml.unmarshal(Tags.class, response.body().charStream()); } catch (ErrorResponseException e) { if (e.errorResponse().errorCode() != ErrorCode.NO_SUCH_TAG_SET) { throw e; } } return new Tags(); }
Source:
<code>public ListenableFuture<Void> getCloseFuture() { synchronized (mReleaseLock) { if (mReleaseFuture == null) { mReleaseFuture = CallbackToFutureAdapter.getFuture( new CallbackToFutureAdapter.Resolver<Void>() { @Override public Object attachCompleter(@NonNull CallbackToFutureAdapter.Completer<Void> completer) { synchronized (mReleaseLock) { <START> Preconditions.checkState(Thread.holdsLock(mReleaseLock)); <END> Preconditions.checkState(mReleaseCompleter == null, "Release completer expected to be null"); mReleaseCompleter = completer; return "Release[imageProxy=" + FakeImageProxy.this + "]"; } } }); } return mReleaseFuture; } }</code><technical_language>add synchronized block, this check removed</technical_language>

Target:
public ListenableFuture<Void> getCloseFuture() { synchronized (mReleaseLock) { if (mReleaseFuture == null) { mReleaseFuture = CallbackToFutureAdapter.getFuture( new CallbackToFutureAdapter.Resolver<Void>() { @Override public Object attachCompleter(@NonNull CallbackToFutureAdapter.Completer<Void> completer) { synchronized (mReleaseLock) { Preconditions.checkState(mReleaseCompleter == null, "Release completer expected to be null"); mReleaseCompleter = completer; return "Release[imageProxy=" + FakeImageProxy.this + "]"; } } }); } return mReleaseFuture; } }
Source:
<code>public static List<Integer> delimitedStringToIntegerList(String delimitedString, String delimiter) { List<Integer> ret = new ArrayList<>(); String[] tokens = delimitedString.split(delimiter); for (String token : tokens) { token = token.trim(); if (token.length() == 0) { } else { ret.add(Integer.valueOf(token)); <START> } <END> } return ret; }</code><technical_language>simplify this if statement else</technical_language>

Target:
public static List<Integer> delimitedStringToIntegerList(String delimitedString, String delimiter) { List<Integer> ret = new ArrayList<>(); String[] tokens = delimitedString.split(delimiter); for (String token : tokens) { token = token.trim(); if (token.length() != 0) { ret.add(Integer.valueOf(token)); } } return ret; }
Source:
<code>public void bindingChanged(BindingProvider provider, String itemName) { logger.debug("Plex binding changed"); if (provider instanceof PlexBindingProvider) { PlexBindingProvider plexProvider = (PlexBindingProvider) provider; PlexBindingConfig config = plexProvider.getConfig(itemName); if (config != null) <START> setInitialState(config); <END> } }</code><technical_language>please curly braces this is a Oneliner</technical_language>

Target:
public void bindingChanged(BindingProvider provider, String itemName) { logger.trace("Plex binding changed"); if (provider instanceof PlexBindingProvider) { PlexBindingProvider plexProvider = (PlexBindingProvider) provider; PlexBindingConfig config = plexProvider.getConfig(itemName); if (config != null) { setInitialState(config); } } }
Source:
<code>private HTInterval getRelevantInterval(long t, int key) throws TimeRangeException, ClosedChannelException { checkValidTime(t); Deque<HTNode> queue = new LinkedList<>(); queue.add(fSht.getRootNode()); HTInterval interval = null; while (interval == null && !queue.isEmpty()) { HTNode currentNode = queue.pop(); <START> if ((currentNode.getNodeType() == HTNode.NodeType.CORE)) { <END> queue.addAll(fSht.selectNextChildren((CoreNode) currentNode, t)); } interval = currentNode.getRelevantInterval(key, t); } return interval; }</code><technical_language>2 ((</technical_language>

Target:
private HTInterval getRelevantInterval(long t, int key) throws TimeRangeException, ClosedChannelException { checkValidTime(t); Deque<HTNode> queue = new LinkedList<>(); queue.add(fSht.getRootNode()); HTInterval interval = null; while (interval == null && !queue.isEmpty()) { HTNode currentNode = queue.pop(); if (currentNode.getNodeType() == HTNode.NodeType.CORE) { queue.addAll(fSht.selectNextChildren((CoreNode) currentNode, t)); } interval = currentNode.getRelevantInterval(key, t); } return interval; }
Source:
<code>@NonNull T execute() throws IOException, SchemaViolationError; @NonNull GraphCall<T> enqueue(@NonNull Callback<T> callback); interface Callback<T extends AbstractResponse<T>> { <START> void onResponse(@NonNull T response); <END> void onFailure(@NonNull Throwable t); }</code><technical_language>add a new line</technical_language>

Target:
@NonNull GraphResponse<T> execute() throws GraphError; @NonNull GraphCall<T> enqueue(@NonNull Callback<T> callback); interface Callback<T extends AbstractResponse<T>> { void onResponse(@NonNull GraphResponse<T> response); void onFailure(@NonNull GraphError error); }
Source:
<code>public static InetAddress intToInetAddress(int hostAddress) { InetAddress inetAddress; <START> String hostName; <END> hostName = "" + (0xff & hostAddress) + "." + (0xff & (hostAddress >> 8)) + "." + (0xff & (hostAddress >> 16)) + "." + (0xff & (hostAddress >> 24)); try { inetAddress = InetAddress.getByName(hostName); } catch (UnknownHostException e) { return null; } return inetAddress; }</code><technical_language>InetAddress.getByAddress(byte[]) instead? byte[] addressBytes = { 0xff & hostAddress, (0xff & (hostAddress >> 8)), ... }; try { inetAddress = InetAddress.getByAddress(addressBytes); } catch(UnknownHostException e) { return null; }</technical_language>

Target:
public static InetAddress intToInetAddress(int hostAddress) { InetAddress inetAddress; byte[] addressBytes = { (byte)(0xff & hostAddress), (byte)(0xff & (hostAddress >> 8)), (byte)(0xff & (hostAddress >> 16)), (byte)(0xff & (hostAddress >> 24)) }; try { inetAddress = InetAddress.getByAddress(addressBytes); } catch(UnknownHostException e) { return null; } return inetAddress; }
Source:
<code>public boolean login(HttpServletRequest request, HttpServletResponse response) throws IOException { if (isLoggedIn()) { return true; } LOG.debug("Login " + this); <START> <END> if (OAuthProtocol.isOAuthFinal(request)) { String redirectUrl = oauth.getTargetUrl(request); if (redirectUrl == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return false; } LOG.debug("Login-FINAL " + this); login(oauth.loginPhase2(request, response)); if (isLoggedIn()) { LOG.debug("Login-SUCCESS " + this); response.sendRedirect(redirectUrl); return true; } else { response.sendError(HttpStatus.SC_UNAUTHORIZED); return false; } } else { LOG.debug("Login-PHASE1 " + this); oauth.loginPhase1(request, response); return false; } }</code><technical_language>Nit: unnecessary new line</technical_language>

Target:
public boolean login(HttpServletRequest request, HttpServletResponse response) throws IOException { if (isLoggedIn()) { return true; } LOG.debug("Login " + this); if (OAuthProtocol.isOAuthFinal(request)) { String redirectUrl = oauth.getTargetUrl(request); if (redirectUrl == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return false; } LOG.debug("Login-Retrieve-User " + this); retrieveUser(oauth.loginPhase2(request, response)); if (isLoggedIn()) { LOG.debug("Login-SUCCESS " + this); response.sendRedirect(redirectUrl); return true; } else { response.sendError(HttpStatus.SC_UNAUTHORIZED); return false; } } else { LOG.debug("Login-PHASE1 " + this); oauth.loginPhase1(request, response); return false; } }
Source:
<code>public CloudBlobMetadata getOldestExpiredBlob(String partitionPath) throws CloudStorageException { List<CloudBlobMetadata> deadBlobs = requestAgent.doWithRetries( <START> () -> cloudDestination.getExpiredBlobs(partitionPath, System.currentTimeMillis(), queryLimit), "GetDeadBlobs", <END> partitionPath); return deadBlobs.isEmpty() ? null : deadBlobs.get(0); }</code><technical_language>query limit 1 in method interested in a single blob</technical_language>

Target:
public CloudBlobMetadata getOldestExpiredBlob(String partitionPath) throws CloudStorageException { List<CloudBlobMetadata> deadBlobs = requestAgent.doWithRetries( () -> cloudDestination.getExpiredBlobs(partitionPath, 1, System.currentTimeMillis(), 1), "GetDeadBlobs", partitionPath); return deadBlobs.isEmpty() ? null : deadBlobs.get(0); }
Source:
<code>private void addInstrumentedMethod( Map<Method, MethodMetrics> existingMethodMetrics, Method method, MethodMetrics methodMetrics) { if (!isMethodAllowed(method)) { return; } for (Map.Entry<Method, MethodMetrics> existingMethodMetric : existingMethodMetrics.entrySet()) { <START> String invocationsIdMetricName = existingMethodMetric.getValue().invocationsId.name(); <END> if (invocationsIdMetricName.equals(methodMetrics.invocationsId.name())) { throw new MetricNameCollisionException( target, invocationsIdMetricName, existingMethodMetric.getKey(), method); } } existingMethodMetrics.put(method, methodMetrics); }</code><technical_language>if treating existingMethodMetrics a ConcurrentHashMap putIfAbsent semantics better/prefable. In theory allow avoid this collision check safely pre-exists</technical_language>

Target:
private void addInstrumentedMethod( Map<Method, MethodMetrics> existingMethodMetrics, Method method, MethodMetrics methodMetrics) { if (!isMethodAllowed(method)) { return; } existingMethodMetrics.putIfAbsent(method, methodMetrics); }
Source:
<code>private void maybeNotifyListeners(List<Broadcaster.BroadcastRequest> broadcastRequests) { int numOfCompletedBroadcastsTarget = Math.max(1, Math.min(numPeersForBroadcast, 3)); if (numOfCompletedBroadcasts == numOfCompletedBroadcastsTarget) { broadcastRequests.stream() .filter(broadcastRequest -> broadcastRequest.getListener() != null) .map(Broadcaster.BroadcastRequest::getListener) .forEach(listener -> listener.onSufficientlyBroadcast(broadcastRequests)); } else { int openRequests = numPeersForBroadcast - numOfCompletedBroadcasts - numOfFailedBroadcasts; int maxPossibleSuccessCases = openRequests + numOfCompletedBroadcasts; <START> if (maxPossibleSuccessCases == numOfCompletedBroadcastsTarget - 1) { broadcastRequests.stream() .filter(broadcastRequest -> broadcastRequest.getListener() != null) .map(Broadcaster.BroadcastRequest::getListener) .forEach(listener -> listener.onNotSufficientlyBroadcast(numOfCompletedBroadcasts, numOfFailedBroadcasts)); } else if (timeoutTriggered && numOfCompletedBroadcasts < numOfCompletedBroadcastsTarget) { broadcastRequests.stream() .filter(broadcastRequest -> broadcastRequest.getListener() != null) .map(Broadcaster.BroadcastRequest::getListener) .forEach(listener -> listener.onNotSufficientlyBroadcast(numOfCompletedBroadcasts, numOfFailedBroadcasts)); } <END> } }</code><technical_language>cases combined block</technical_language>

Target:
private void maybeNotifyListeners(List<Broadcaster.BroadcastRequest> broadcastRequests) { int numOfCompletedBroadcastsTarget = Math.max(1, Math.min(numPeersForBroadcast, 3)); if (numOfCompletedBroadcasts == numOfCompletedBroadcastsTarget) { broadcastRequests.stream() .filter(broadcastRequest -> broadcastRequest.getListener() != null) .map(Broadcaster.BroadcastRequest::getListener) .forEach(listener -> listener.onSufficientlyBroadcast(broadcastRequests)); } else { int maxPossibleSuccessCases = numPeersForBroadcast - numOfFailedBroadcasts; boolean notEnoughSucceededOrOpen = maxPossibleSuccessCases == numOfCompletedBroadcastsTarget - 1; boolean timeoutAndNotEnoughSucceeded = timeoutTriggered && numOfCompletedBroadcasts < numOfCompletedBroadcastsTarget; if (notEnoughSucceededOrOpen || timeoutAndNotEnoughSucceeded) { broadcastRequests.stream() .filter(broadcastRequest -> broadcastRequest.getListener() != null) .map(Broadcaster.BroadcastRequest::getListener) .forEach(listener -> listener.onNotSufficientlyBroadcast(numOfCompletedBroadcasts, numOfFailedBroadcasts)); } } }
Source:
<code>public Map<String, ServerImpl> getServers() { Map<String, List<PortBinding>> ports = info.getNetworkSettings().getPorts(); <START> Map<String, String> labels = info.getConfig().getLabels(); <END> return addDefaultReferenceForServersWithoutReference( addRefAndUrlToServers(getServersWithFilledPorts(containerHost, ports != null ? ports : Collections.emptyMap()), labels != null ? labels : Collections.emptyMap())); }</code><technical_language>getNetworkSettings getConfig null</technical_language>

Target:
public Map<String, ServerImpl> getServers() { Map<String, List<PortBinding>> ports; if (info.getNetworkSettings() != null && info.getNetworkSettings().getPorts() != null) { ports = info.getNetworkSettings().getPorts(); } else { ports = Collections.emptyMap(); } Map<String, String> labels; if (info.getConfig() != null && info.getConfig().getLabels() != null) { labels = info.getConfig().getLabels(); } else { labels = Collections.emptyMap(); } return addDefaultReferenceForServersWithoutReference( addRefAndUrlToServers( getServersWithFilledPorts(containerHost, ports), labels)); }
Source:
<code>public JmsConfiguration incomingWebServiceJmsConfiguration(final JmsConfigurationFactory jmsConfigurationFactory) { <START> return jmsConfigurationFactory.initializeConfiguration("jms.incoming.ws.requests", <END> this.incomingWebServiceRequestMessageListener); }</code><technical_language>JMS Template needed here, initialize JMS Template</technical_language>

Target:
public JmsConfiguration incomingWebServiceJmsConfiguration(final JmsConfigurationFactory jmsConfigurationFactory) { return jmsConfigurationFactory.initializeReceiveConfiguration("jms.incoming.ws.requests", this.incomingWebServiceRequestMessageListener); }
Source:
<code>public void testPruneOneColumn() throws Exception { String inputFile = "src/test/java/org/apache/parquet/tools/data/test.parquet"; String outputFile = rand.nextInt() + ".parquet"; String cargs[] = {inputFile, outputFile, "gender"}; executeCommandLine(cargs); ParquetMetadata pmd = ParquetFileReader.readFooter(conf, new Path(outputFile), ParquetMetadataConverter.NO_FILTER); MessageType schema = pmd.getFileMetaData().getSchema(); List<Type> fields = schema.getFields(); <START> assertEquals(fields.size(), 2); <END> assertEquals(fields.get(0).getName(), "name"); assertEquals(fields.get(1).getName(), "age"); }</code><technical_language>Checking in binary parquet files is future proof. is a idea create input file in test remove end. (There examples in tests do so.)</technical_language>

Target:
public void testPruneOneColumn() throws Exception { String inputFile = createParquetFile("input"); String outputFile = createTempFile("output"); String cargs[] = {inputFile, outputFile, "Gender"}; executeCommandLine(cargs); ParquetMetadata pmd = ParquetFileReader.readFooter(conf, new Path(outputFile), ParquetMetadataConverter.NO_FILTER); MessageType schema = pmd.getFileMetaData().getSchema(); List<Type> fields = schema.getFields(); assertEquals(fields.size(), 3); assertEquals(fields.get(0).getName(), "DocId"); assertEquals(fields.get(1).getName(), "Name"); assertEquals(fields.get(2).getName(), "Links"); List<Type> subFields = fields.get(2).asGroupType().getFields(); assertEquals(subFields.size(), 2); assertEquals(subFields.get(0).getName(), "Backward"); assertEquals(subFields.get(1).getName(), "Forward"); List<String> prunePaths = Arrays.asList("Gender"); validateColumns(inputFile, prunePaths); }
Source:
<code>public void testHalfNumComputeTasks() { final int numComputeTask = 4; final Collection<EvaluatorParameters> activeEvaluators = <START> generateEvaluatorParameters(4, new int[][]{{2500}, {2500}, {2500}, {2500}}); <END> final int upperBoundToDelete = (int) Math.ceil((double) numComputeTask / 2); final Plan plan = ilpSolverOptimizer.optimize(activeEvaluators, numComputeTask / 2 + 1); assertEquals(0, plan.getEvaluatorsToAdd().size()); assertTrue("The number of evaluators to be deleted should be <= " + upperBoundToDelete, plan.getEvaluatorsToDelete().size() <= upperBoundToDelete); }</code><technical_language>change numComputeTask 4</technical_language>

Target:
public void testHalfNumComputeTasks() { final int numComputeTasks = 4; final Collection<EvaluatorParameters> activeEvaluators = generateEvaluatorParameters(numComputeTasks, new int[][]{{2500}, {2500}, {2500}, {2500}}); final int upperBoundToDelete = (int) Math.ceil((double) numComputeTasks / 2); final Plan plan = ilpSolverOptimizer.optimize(activeEvaluators, numComputeTasks / 2 + 1); assertEquals(0, plan.getEvaluatorsToAdd().size()); assertTrue("The number of evaluators to be deleted should be <= " + upperBoundToDelete, plan.getEvaluatorsToDelete().size() <= upperBoundToDelete); }
Source:
<code>public void setPollInterval(Integer interval) { <START> this.pollInterval = interval; <END> updateScheduler(); }</code><technical_language>metatype file this a minimum of 1. enforcing here</technical_language>

Target:
public void setPollInterval(Integer interval) { this.pollInterval = Math.max(1, interval); updateScheduler(); }
Source:
<code>private <START> final void <END> clearActivations() { deactivateHandlers(handlerActivations); for (IHandlerActivation activation : handlerActivations) { IHandler handler = activation.getHandler(); if (handler != null) { try { handler.dispose(); } catch (Exception e) { WorkbenchPlugin.log("Failed to dispose handler for " + activation.getCommandId(), e); } catch (LinkageError e) { WorkbenchPlugin.log("Failed to dispose handler for " + activation.getCommandId(), e); } } } handlerActivations.clear(); }</code><technical_language>private methods final. Please remove this modifier</technical_language>

Target:
private void clearActivations() { deactivateHandlers(handlerActivations); for (IHandlerActivation activation : handlerActivations) { final IHandler handler = activation.getHandler(); if (handler != null) { SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { handler.dispose(); } @Override public void handleException(Throwable exception) { WorkbenchPlugin.log("Failed to dispose handler for " + activation.getCommandId(), exception); } }); } } handlerActivations.clear(); }
Source:
<code>public JoinOperatorInfo mergeWith(JoinOperatorInfo other) { checkState(this.joinType.equals(other.joinType), "different join types"); long[] logHistogramProbes = new long[HISTOGRAM_BUCKETS]; long[] logHistogramOutput = new long[HISTOGRAM_BUCKETS]; for (int i = 0; i < HISTOGRAM_BUCKETS; i++) { logHistogramProbes[i] = this.logHistogramProbes[i] + other.logHistogramProbes[i]; logHistogramOutput[i] = this.logHistogramOutput[i] + other.logHistogramOutput[i]; } long mergedSourcePositions = this.lookupSourcePositions; if (mergedSourcePositions >= 0 && other.lookupSourcePositions >= 0) { mergedSourcePositions += other.lookupSourcePositions; } else { <START> mergedSourcePositions = other.lookupSourcePositions; <END> } return new JoinOperatorInfo(this.joinType, logHistogramProbes, logHistogramOutput, mergedSourcePositions); }</code><technical_language>this.lookupSourcePositions > 0 other.lookupSourcePositions < 0</technical_language>

Target:
public JoinOperatorInfo mergeWith(JoinOperatorInfo other) { checkState(this.joinType.equals(other.joinType), "different join types"); long[] logHistogramProbes = new long[HISTOGRAM_BUCKETS]; long[] logHistogramOutput = new long[HISTOGRAM_BUCKETS]; for (int i = 0; i < HISTOGRAM_BUCKETS; i++) { logHistogramProbes[i] = this.logHistogramProbes[i] + other.logHistogramProbes[i]; logHistogramOutput[i] = this.logHistogramOutput[i] + other.logHistogramOutput[i]; } Optional<Long> mergedSourcePositions = Optional.empty(); if (this.lookupSourcePositions.isPresent() || other.lookupSourcePositions.isPresent()) { mergedSourcePositions = Optional.of(this.lookupSourcePositions.orElse(0L) + other.lookupSourcePositions.orElse(0L)); } return new JoinOperatorInfo(this.joinType, logHistogramProbes, logHistogramOutput, mergedSourcePositions); }
Source:
<code><START> public void upgrade() { <END> try { final String description = "JClouds cloud " + getCloud().name + "." + name + " - auto-migrated"; String ju = getJenkinsUser(); if (Strings.isNullOrEmpty(getCredentialsId()) && !Strings.isNullOrEmpty(ju)) { setCredentialsId(convertJenkinsUser(ju, description, getCloud().getGlobalPrivateKey())); jenkinsUser = null; } if (Strings.isNullOrEmpty(getAdminCredentialsId())) { StandardUsernameCredentials u = null; String au = getAdminUser(); if (Strings.isNullOrEmpty(vmPassword)) { if (!au.equals("root")) { String privateKey = getCloud().getGlobalPrivateKey(); u = new BasicSSHUserPrivateKey(CredentialsScope.SYSTEM, null, au, new BasicSSHUserPrivateKey.DirectEntryPrivateKeySource(privateKey), null, description); } } else { u = new UsernamePasswordCredentialsImpl( CredentialsScope.SYSTEM, null, description, au, vmPassword); } setAdminCredentialsId(storeCredentials(u)); } } catch (Exception e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); throw e; } }</code><technical_language>This is a public api is for migration only</technical_language>

Target:
void upgrade() { try { final String description = "JClouds cloud " + getCloud().name + "." + name + " - auto-migrated"; String ju = getJenkinsUser(); if (Strings.isNullOrEmpty(getCredentialsId()) && !Strings.isNullOrEmpty(ju)) { setCredentialsId(convertJenkinsUser(ju, description, getCloud().getGlobalPrivateKey())); jenkinsUser = null; } if (Strings.isNullOrEmpty(getAdminCredentialsId())) { StandardUsernameCredentials u = null; String au = getAdminUser(); if (Strings.isNullOrEmpty(vmPassword)) { if (!au.equals("root")) { String privateKey = getCloud().getGlobalPrivateKey(); u = new BasicSSHUserPrivateKey(CredentialsScope.SYSTEM, null, au, new BasicSSHUserPrivateKey.DirectEntryPrivateKeySource(privateKey), null, description); } } else { u = new UsernamePasswordCredentialsImpl( CredentialsScope.SYSTEM, null, description, au, vmPassword); } setAdminCredentialsId(storeCredentials(u)); } } catch (Exception e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); throw e; } }
Source:
<code>public void setup(ManagementClient managementClient, String containerId) throws Exception { ModelNode addTestLogOp = org.jboss.as.controller.operations.common.Util.createAddOperation(PathAddress.pathAddress().append(SUBSYSTEM, "logging") <START> .append("periodic-rotating-file-handler", getHandlerName())); <END> addTestLogOp.get("level").set(getLevel()); addTestLogOp.get("append").set("true"); addTestLogOp.get("suffix").set(".yyyy-MM-dd"); ModelNode file = new ModelNode(); file.get("relative-to").set("jboss.server.log.dir"); file.get("path").set(getLogFileName()); addTestLogOp.get("file").set(file); addTestLogOp.get("formatter").set("%-5p [%c] (%t) %s%e%n"); applyUpdate(managementClient.getControllerClient(), addTestLogOp, false); Collection<String> categories = getCategories(); if (categories == null || categories.isEmpty()) { LOGGER.warn("getCategories() returned empty collection."); return; } for (String category : categories) { if (category == null || category.length() == 0) { LOGGER.warn("Empty category name provided."); continue; } ModelNode op = org.jboss.as.controller.operations.common.Util.createAddOperation(PathAddress.pathAddress().append(SUBSYSTEM, "logging").append("logger", category)); op.get("level").set(getLevel()); op.get("handlers").add(getHandlerName()); applyUpdate(managementClient.getControllerClient(), op, false); } }</code><technical_language>I a file-handler configuration is complex slight overhead is WriteHandler.preWrite() invoked. a big deal though</technical_language>

Target:
public void setup(ManagementClient managementClient, String containerId) throws Exception { final Operations.CompositeOperationBuilder builder = Operations.CompositeOperationBuilder.create(); final ModelNode handlerAddress = Operations.createAddress(SUBSYSTEM, "logging", "file-handler", getHandlerName()); ModelNode addTestLogOp = Operations.createAddOperation(handlerAddress); addTestLogOp.get("level").set(getLevel()); addTestLogOp.get("append").set("true"); ModelNode file = new ModelNode(); file.get("relative-to").set("jboss.server.log.dir"); file.get("path").set(getLogFileName()); addTestLogOp.get("file").set(file); addTestLogOp.get("formatter").set("%-5p [%c] (%t) %s%e%n"); builder.addStep(addTestLogOp); removeOps.add(Operations.createRemoveOperation(handlerAddress)); Collection<String> categories = getCategories(); if (categories == null || categories.isEmpty()) { LOGGER.warn("getCategories() returned empty collection."); return; } for (String category : categories) { if (category == null || category.isEmpty()) { LOGGER.warn("Empty category name provided."); continue; } final ModelNode loggerAddress = Operations.createAddress(SUBSYSTEM, "logging", "logger", category); ModelNode op = Operations.createAddOperation(loggerAddress); op.get("level").set(getLevel()); op.get("handlers").add(getHandlerName()); builder.addStep(op); removeOps.addFirst(Operations.createRemoveOperation(loggerAddress)); } applyUpdate(managementClient.getControllerClient(), builder.build(), false); }