auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private Set<GenericItem> getItemsInVisibilityCond(EList<VisibilityRule> ruleList) { Set<GenericItem> items = new HashSet<GenericItem>(); <START> if (ruleList != null) { <END> for (VisibilityRule rule : ruleList) { String itemName = rule.getItem(); if (itemName != null) { try { Item item = itemUIRegistry.getItem(itemName); if (item instanceof GenericItem) { final GenericItem gItem = (GenericItem) item; items.add(gItem); } } catch (ItemNotFoundException e) { } } } } return items; }</code><technical_language>rulesList null, widget#getVisibility returns a list instance</technical_language>

Target:
private Set<GenericItem> getItemsInVisibilityCond(EList<VisibilityRule> ruleList) { Set<GenericItem> items = new HashSet<GenericItem>(); for (VisibilityRule rule : ruleList) { String itemName = rule.getItem(); if (itemName != null) { try { Item item = itemUIRegistry.getItem(itemName); if (item instanceof GenericItem) { items.add((GenericItem) item); } } catch (ItemNotFoundException e) { } } } return items; }
Source:
<code>public void onGenericMessage( final GenericMessageEvent event ) { String text = event.getMessage(); Matcher matcher = FAKE_NEWS_PATTERN.matcher( text ); Matcher helpMatcher = FAKE_NEWS_HELP_PATTERN.matcher( text ); if ( helpMatcher.matches() ) { <START> event.respondWith( "Check your DMs fam" ); <END> for ( String line : HELP_MESSAGE.split( "\n" ) ) { event.respondPrivateMessage( line ); } } else if ( matcher.matches() ) { currentNews( event, matcher, fakeNewsFeedsByCategory, DEFAULT_CATEGORY, logger ); } }</code><technical_language>avoid spam, this line out</technical_language>

Target:
public void onGenericMessage( final GenericMessageEvent event ) { String text = event.getMessage(); Matcher matcher = FAKE_NEWS_PATTERN.matcher( text ); Matcher helpMatcher = FAKE_NEWS_HELP_PATTERN.matcher( text ); if ( helpMatcher.matches() ) { for ( String line : HELP_MESSAGE.split( "\n" ) ) { event.respondPrivateMessage( line ); } } else if ( matcher.matches() ) { currentNews( event, matcher, fakeNewsFeedsByCategory, DEFAULT_CATEGORY, logger ); } }
Source:
<code>public int getPointAreaOffset() { int pixelCoordinate = 0; IAxis[] xAxes = getSwtChart().getAxisSet().getXAxes(); ISeries[] series = fSwtChart.getSeriesSet().getSeries(); if ((xAxes.length > 0) && (series.length > 0) && (series[0].getXSeries() != null) && (series[0].getXSeries().length > 0)) { IAxis axis = xAxes[0]; double[] xSeries = series[0].getXSeries(); <START> double minx = Double.MAX_VALUE; <END> for (double x : xSeries) { if (minx > x) { minx = x; } } pixelCoordinate = axis.getPixelCoordinate(minx); } return getSwtChart().toControl(getSwtChart().getPlotArea().toDisplay(pixelCoordinate, 0)).x; }</code><technical_language>minX</technical_language>

Target:
public int getPointAreaOffset() { int pixelCoordinate = 0; IAxis[] xAxes = getSwtChart().getAxisSet().getXAxes(); ISeries[] series = fSwtChart.getSeriesSet().getSeries(); if ((xAxes.length > 0) && (series.length > 0) && (series[0].getXSeries() != null) && (series[0].getXSeries().length > 0)) { IAxis axis = xAxes[0]; double[] xSeries = series[0].getXSeries(); double minX = Double.MAX_VALUE; for (double x : xSeries) { if (minX > x) { minX = x; } } pixelCoordinate = axis.getPixelCoordinate(minX); } return getSwtChart().toControl(getSwtChart().getPlotArea().toDisplay(pixelCoordinate, 0)).x; }
Source:
<code>protected void addPages() { try { OseeStatusContributionItemFactory.addTo(this, true); String editorName = getResultsEditorProvider().getEditorName(); <START> if (getTabs() == null || getTabs().isEmpty()) { <END> tabs.add(new ResultsEditorHtmlTab("Error", "Error", AHTML.simplePage("Error: No tabs were defined for \"" + editorName + "\""))); } for (IResultsEditorTab tab : getTabs()) { addResultsTab(tab); } if (startPage == null) { addResultsTab(new ResultsEditorHtmlTab("Error", "Error", AHTML.simplePage("Error: Pages creation error for \"" + editorName + "\"; StartPage == null"))); } setPartName(editorName); setActivePage(startPage); } catch (Exception ex) { OseeLog.log(Activator.class, Level.SEVERE, ex); } }</code><technical_language>remove getTabs() method do this</technical_language>

Target:
protected void addPages() { try { OseeStatusContributionItemFactory.addTo(this, true); String editorName = getResultsEditorProvider().getEditorName(); for (IResultsEditorTab tab : getTabs()) { addResultsTab(tab); } if (startPage == null) { addResultsTab(new ResultsEditorHtmlTab("Error", "Error", AHTML.simplePage("Error: Pages creation error for \"" + editorName + "\"; StartPage == null"))); } setPartName(editorName); setActivePage(startPage); } catch (Exception ex) { OseeLog.log(Activator.class, Level.SEVERE, ex); } }
Source:
<code>private DefaultTeslaAether getAetherClient() { List<String> remoteUriList = extensionsConfig.getRemoteRepositories(); List<Repository> remoteRepositories = Lists.newArrayList(); for (String uri : remoteUriList) { try { URI u = new URI(uri); Repository r = new Repository(uri); if (u.getUserInfo() != null) { String[] auth = u.getUserInfo().split(":", 2); if (auth.length == 2) { r.setUsername(auth[0]); r.setPassword(auth[1]); } else { log.warn( "Invalid credentials in repository URI, expecting [<user>:<password>], got [%s] for [%s]", u.getUserInfo(), uri ); } } remoteRepositories.add(r); } catch (URISyntaxException e) { throw Throwables.propagate(e); } } if (log.isTraceEnabled() || log.isDebugEnabled()) { return new DefaultTeslaAether( extensionsConfig.getLocalRepository(), remoteRepositories.toArray(new Repository[remoteRepositories.size()]) ); } <START> PrintStream oldOut = System.out; <END> try { System.setOut( new PrintStream( new OutputStream() { @Override public void write(int b) throws IOException { } @Override public void write(byte[] b) throws IOException { } @Override public void write(byte[] b, int off, int len) throws IOException { } } , false, StringUtils.UTF8_STRING ) ); return new DefaultTeslaAether( extensionsConfig.getLocalRepository(), remoteRepositories.toArray(new Repository[remoteRepositories.size()]) ); } catch (UnsupportedEncodingException e) { throw new IllegalStateException(e); } finally { System.setOut(oldOut); } }</code><technical_language>is this done</technical_language>

Target:
private DefaultTeslaAether getAetherClient() { List<String> remoteUriList = remoteRepositories; List<Repository> remoteRepositories = Lists.newArrayList(); for (String uri : remoteUriList) { try { URI u = new URI(uri); Repository r = new Repository(uri); if (u.getUserInfo() != null) { String[] auth = u.getUserInfo().split(":", 2); if (auth.length == 2) { r.setUsername(auth[0]); r.setPassword(auth[1]); } else { log.warn( "Invalid credentials in repository URI, expecting [<user>:<password>], got [%s] for [%s]", u.getUserInfo(), uri ); } } remoteRepositories.add(r); } catch (URISyntaxException e) { throw Throwables.propagate(e); } } if (log.isTraceEnabled() || log.isDebugEnabled()) { return new DefaultTeslaAether( localRepository, remoteRepositories.toArray(new Repository[remoteRepositories.size()]) ); } PrintStream oldOut = System.out; try { System.setOut( new PrintStream( new OutputStream() { @Override public void write(int b) throws IOException { } @Override public void write(byte[] b) throws IOException { } @Override public void write(byte[] b, int off, int len) throws IOException { } } , false, StringUtils.UTF8_STRING ) ); return new DefaultTeslaAether( localRepository, remoteRepositories.toArray(new Repository[remoteRepositories.size()]) ); } catch (UnsupportedEncodingException e) { throw new IllegalStateException(e); } finally { System.setOut(oldOut); } }
Source:
<code>private String format(PhoneNumberFormat format) { if (this.number != null && this.regionCode != null) { try { PhoneNumber phoneNumber = PHONE_UTIL.parse(this.number, this.regionCode); if (PHONE_UTIL.isValidNumber(phoneNumber)) { return PHONE_UTIL.format(phoneNumber, format); } } catch (Exception e) { } } <START> return number; <END> }</code><technical_language>this throw if number regionCode null? if number regionCode invalid? cases this throw? catching Exceptions specific exceptions NumberFormatException? unit tests test edge cases</technical_language>

Target:
private String format(PhoneNumberFormat format) { if (this.number != null && this.regionCode != null) { try { PhoneNumber phoneNumber = PHONE_UTIL.parse(this.number, this.regionCode); if (PHONE_UTIL.isValidNumber(phoneNumber)) { return PHONE_UTIL.format(phoneNumber, format); } } catch (NumberParseException e) { } } return number; }
Source:
<code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.single_app_view); int position = getIntent().getIntExtra("position", -1); appRecord = CommCareApplication._().getAppAtIndex(position); if (appRecord == null) { Intent i = new Intent(getApplicationContext(), AppManagerActivity.class); startActivity(i); finish(); } String appName = appRecord.getDisplayName(); <START> TextView tv = (TextView)findViewById(R.id.app_name); <END> tv.setText(appName); }</code><technical_language>I helpful display App Version in this metadata</technical_language>

Target:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.single_app_view); int position = getIntent().getIntExtra("position", -1); appRecord = getAppForPosition(position); if (appRecord == null) { Intent i = new Intent(getApplicationContext(), AppManagerActivity.class); startActivity(i); finish(); } String appName = appRecord.getDisplayName(); TextView tv = (TextView)findViewById(R.id.app_name); tv.setText(appName); }
Source:
<code>private void applyColorPalette() { <START> switch (PreferenceManager.getDefaultSharedPreferences(this).getString("color_palette", "light")) { <END> case "light": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); break; case "dark": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); break; case "auto": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM); break; } }</code><technical_language>PreferenceManager directly, PreferencesRepository, inject. - this abstraction free for kind of redesign in future, is in, it</technical_language>

Target:
private void applyColorPalette() { switch (PreferenceManager.getDefaultSharedPreferences(this).getString(PreferencesRepository.KEY_PREF_COLOR_PALETTE, PreferencesRepository.DEFAULT_PREF_COLOR_PALETTE)) { case "light": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); break; case "dark": AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); break; case "auto": if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM); } else { AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY); } break; } }
Source:
<code>private static xml getMediaIdForUploadedFileTokenSynchronous(Context context, String ks, String uploadTocken, String fileName, String mimetype) { try { RestAdapter restAdapter = KalturaRestAdapter.buildAdapter(context); String mediaTypeConverted = FileUtilities.kalturaCodeFromMimeType(mimetype); return restAdapter.create(KalturaAPIInterface.class).getMediaIdForUploadedFileTokenSynchronous(ks, uploadTocken, fileName, mediaTypeConverted); } catch (Exception E) { <START> Log.e(APIHelpers.LOG_TAG, E.getMessage()); <END> return null; } }</code><technical_language>LoggingUtility.LogException()</technical_language>

Target:
private static xml getMediaIdForUploadedFileTokenSynchronous(Context context, String ks, String uploadTocken, String fileName, String mimetype) { try { RestAdapter restAdapter = KalturaRestAdapter.buildAdapter(context); String mediaTypeConverted = FileUtilities.kalturaCodeFromMimeType(mimetype); return restAdapter.create(KalturaAPIInterface.class).getMediaIdForUploadedFileTokenSynchronous(ks, uploadTocken, fileName, mediaTypeConverted); } catch (Exception E) { Log.e(APIHelpers.LOG_TAG, E.toString()); return null; } }
Source:
<code>private static InputStream getRegistryResource(MessageContext synCtx, String key) { InputStream inputStream = null; Object entry = synCtx.getEntry(key); if (entry instanceof OMTextImpl) { if (log.isDebugEnabled()) { <START> log.debug("Value for the key is "); <END> } OMTextImpl text = (OMTextImpl) entry; String content = text.getText(); inputStream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)); } return inputStream; }</code><technical_language>is key</technical_language>

Target:
private static InputStream getRegistryResource(MessageContext synCtx, String key) { InputStream inputStream = null; Object entry = synCtx.getEntry(key); if (entry instanceof OMTextImpl) { if (log.isDebugEnabled()) { log.debug("Retrieving the key :" + key); } OMTextImpl text = (OMTextImpl) entry; String content = text.getText(); inputStream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)); } return inputStream; }
Source:
<code><START> private void <END> setAutoSave( @SuppressWarnings("restriction") @Preference(value = IPreferenceConstants.SAVE_AUTOMATICALLY, nodePath = "org.eclipse.ui.workbench") boolean autoSave) { if (autoSave) { System.out.println("ON"); if (!initial) { IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); for (IWorkbenchWindow iWorkbenchWindow : windows) { IWorkbenchPage p = iWorkbenchWindow.getActivePage(); if (p != null) { p.saveAllEditors(false); } } } eventBroker.subscribe(UIEvents.Dirtyable.TOPIC_DIRTY, dirtyHandler); initial = false; } else { eventBroker.unsubscribe(dirtyHandler); System.out.println("OFF"); shutdown(); } }</code><technical_language>@Inject + private forces DI framework reflection. public</technical_language>

Target:
public void setAutoSave( @SuppressWarnings("restriction") @Preference(value = IPreferenceConstants.SAVE_AUTOMATICALLY, nodePath = "org.eclipse.ui.workbench") boolean autoSave) { if (autoSave) { eventBroker.subscribe(UIEvents.Dirtyable.TOPIC_DIRTY, dirtyHandler); } else { eventBroker.unsubscribe(dirtyHandler); shutdown(); } }
Source:
<code>public void cleanup() { try (Statement stmt = connection.createStatement()) { List<String> statusTables = new ArrayList<>(); { ResultSet rs = stmt.executeQuery( String.format(ENGLISH, "SELECT tablename FROM pg_tables WHERE tablename LIKE '%s_%%'", escapeParam(statusTableName)) ); while (rs.next()) { statusTables.add(rs.getString(1)); } } statusTables.forEach( statusTable -> { try { ResultSet rs = stmt.executeQuery( String.format(ENGLISH, "SELECT query_id FROM %s WHERE created_at IS NOT NULL AND completed_at < CURRENT_TIMESTAMP - INTERVAL '%d SECOND'", escapeIdent(statusTable), cleanupDuration.getSeconds()) ); if (rs.next()) { stmt.executeUpdate(String.format("DROP TABLE %s", escapeIdent(statusTable))); <START> } <END> } catch (SQLException e) { logger.warn("Failed to drop expired status table: {}. Ignoring...", statusTable, e); } } ); } catch (SQLException ex) { throw new DatabaseException("Failed to list up expired status tables", ex); } }</code><technical_language>Good catch PostgreSQL's system catalog (e.g. pg_class) table creation timestamp. CREATE TABLE SELECT is option avoid creating empty table. I for release</technical_language>

Target:
public void cleanup() { try (Statement stmt = connection.createStatement()) { List<TableReference> statusTables = new ArrayList<>(); { ResultSet rs = stmt.executeQuery( String.format(ENGLISH, "SELECT schemaname, tablename FROM pg_tables WHERE tablename LIKE '%s_%%'", escapeParam(statusTableNamePrefix)) ); while (rs.next()) { statusTables.add(TableReference.of(rs.getString(1), rs.getString(2))); } } statusTables.forEach( statusTable -> { try { ResultSet rs = stmt.executeQuery( String.format(ENGLISH, "SELECT query_id FROM %s WHERE completed_at < SYSDATE - INTERVAL '%d SECOND'", escapeTableReference(statusTable), cleanupDuration.getSeconds()) ); if (rs.next()) { stmt.executeUpdate(String.format("DROP TABLE %s", escapeTableReference(statusTable))); } } catch (SQLException e) { logger.warn("Failed to drop expired status table: {}. Ignoring this error. To not show this warning message, please confirm that this user has privilege to DROP tables whose name is prefixed with '{}_'", statusTable, statusTableNamePrefix, e); } } ); } catch (SQLException ex) { throw new DatabaseException("Failed to list up expired status tables", ex); } }
Source:
<code>public <T extends Throwable> void expectThrowingOf(Class<T> clazz, String errorMsg, Runnable block) { try { block.run(); flop(errorMsg); } catch (Throwable e) { if (clazz.isInstance(e)) { } else if (org.reactivestreams.tck.support.NonFatal.apply(e)) flop("$errorMsg but " + e); <START> } <END> }</code><technical_language>else rethrow</technical_language>

Target:
public <T extends Throwable> void expectThrowingOf(Class<T> clazz, String errorMsg, Runnable block) throws Throwable { try { block.run(); flop(errorMsg); } catch (Throwable e) { if (clazz.isInstance(e)) { } else if (org.reactivestreams.tck.support.NonFatal.apply(e)) { flop(errorMsg + " but " + e); } else { throw e; } } }
Source:
<code>public List<PermissionSubject> getPermissionCheckSubjects() { List<PermissionSubject> listPermissionSubjects = super.getPermissionCheckSubjects(); listPermissionSubjects.add(new PermissionSubject(getParameters().getStorageDomainId(), <START> VdcObjectType.Disk, <END> ActionGroup.CREATE_DISK)); listPermissionSubjects = QuotaHelper.getInstance().addQuotaPermissionSubject(listPermissionSubjects, getStoragePool(), getQuotaId()); return listPermissionSubjects; }</code><technical_language>VOT.Storage</technical_language>

Target:
public List<PermissionSubject> getPermissionCheckSubjects() { List<PermissionSubject> listPermissionSubjects = super.getPermissionCheckSubjects(); listPermissionSubjects.add(new PermissionSubject(getParameters().getStorageDomainId(), VdcObjectType.Storage, ActionGroup.CREATE_DISK)); listPermissionSubjects = QuotaHelper.getInstance().addQuotaPermissionSubject(listPermissionSubjects, getStoragePool(), getQuotaId()); return listPermissionSubjects; }
Source:
<code>public UninstantiatedDescribable customUninstantiate(@Nonnull UninstantiatedDescribable ud) { <START> Map<String, Object> scmArguments = new HashMap<>(ud.getArguments()); <END> scmArguments.remove("repositoryUrl"); scmArguments.remove("isConfiguredByUrlDynamicValue"); return ud.withArguments(scmArguments); }</code><technical_language>a TreeMap preserve order, IIRC ud.getArguments is backed a TreeMap some other kind of sorted map. change order of fields in some of tests</technical_language>

Target:
public UninstantiatedDescribable customUninstantiate(@Nonnull UninstantiatedDescribable ud) { Map<String, Object> scmArguments = new TreeMap<>(ud.getArguments()); scmArguments.remove("repositoryUrl"); scmArguments.remove("configuredByUrl"); return ud.withArguments(scmArguments); }
Source:
<code>private String getPerformanceRating() { StringBuilder builder = new StringBuilder(); <START> float percentage = Math.round(((((totalElapsedTime / 1000000.0) * 100.0F) / MAX_TICK_DURATION) * 100.0F) / 100.0F); <END> builder.append(NumberUtils.getColorFromPercentage(100 - Math.min(percentage, 100))); int rest = 20; for (int i = (int) Math.min(percentage, 100); i >= 5; i = i - 5) { builder.append(':'); rest--; } builder.append(ChatColor.DARK_GRAY); for (int i = 0; i < rest; i++) { builder.append(':'); } builder.append(" - "); builder.append(rating.getColor() + ChatUtils.humanize(rating.name())); builder.append(ChatColor.GRAY); builder.append(" ("); builder.append(NumberUtils.roundDecimalNumber(percentage)); builder.append("%)"); return builder.toString(); }</code><technical_language>cumbersome this in line</technical_language>

Target:
private String getPerformanceRating() { StringBuilder builder = new StringBuilder(); builder.append(NumberUtils.getColorFromPercentage(100 - Math.min(percentage, 100))); int rest = 20; for (int i = (int) Math.min(percentage, 100); i >= 5; i = i - 5) { builder.append(':'); rest--; } builder.append(ChatColor.DARK_GRAY); for (int i = 0; i < rest; i++) { builder.append(':'); } builder.append(" - "); builder.append(rating.getColor() + ChatUtils.humanize(rating.name())); builder.append(ChatColor.GRAY); builder.append(" ("); builder.append(NumberUtils.roundDecimalNumber(percentage)); builder.append("%)"); return builder.toString(); }
Source:
<code>private void checkTrustedService() { if (getVm() == null || <START> getVmTemplate() == null) { <END> return; } if (getVm().isTrustedService() && !getVmTemplate().isTrustedService()) { auditLogDirector.log(this, AuditLogType.USER_ADD_VM_TEMPLATE_FROM_TRUSTED_TO_UNTRUSTED); } else if (!getVm().isTrustedService() && getVmTemplate().isTrustedService()) { auditLogDirector.log(this, AuditLogType.USER_ADD_VM_TEMPLATE_FROM_UNTRUSTED_TO_TRUSTED); } }</code><technical_language>1. is marked part needed? 2. 'isVmInDb' field</technical_language>

Target:
private void checkTrustedService() { if (!isVmInDb) { return; } if (getVm().isTrustedService() && !getVmTemplate().isTrustedService()) { auditLogDirector.log(this, AuditLogType.USER_ADD_VM_TEMPLATE_FROM_TRUSTED_TO_UNTRUSTED); } else if (!getVm().isTrustedService() && getVmTemplate().isTrustedService()) { auditLogDirector.log(this, AuditLogType.USER_ADD_VM_TEMPLATE_FROM_UNTRUSTED_TO_TRUSTED); } }
Source:
<code>public static void transitionTopologyState(String topologyName, TMasterCommand topologyStateControlCommand, SchedulerStateManagerAdaptor statemgr, TopologyAPI.TopologyState startState, TopologyAPI.TopologyState expectedState, NetworkUtils.TunnelConfig tunnelConfig) throws TMasterException { TopologyAPI.TopologyState state = TMasterUtils.getRuntimeTopologyState(topologyName, statemgr); if (state == null) { throw new TMasterException(String.format( "Topology '%s' is not initialized yet", topologyName)); } if (state == expectedState) { String errMsg = String.format( "Topology {0} command received topology {1} but already in {2} state", topologyStateControlCommand, topologyName, state); <START> throw new TMasterException(errMsg); <END> } if (state != startState) { String errMsg = String.format( "Topology '%s' is not in state '%s'", topologyName, startState); throw new TMasterException(errMsg); } if (!TMasterUtils.sendToTMaster( topologyStateControlCommand.name().toLowerCase(), topologyName, statemgr, tunnelConfig)) { String errMsg = String.format( "Failed to %s topology '%s'", topologyStateControlCommand, topologyName); throw new TMasterException(errMsg); } LOG.log(Level.INFO, "Topology command {0} completed successfully.", topologyStateControlCommand); }</code><technical_language>Sorry, I notice this PR requested a reviewer</technical_language>

Target:
public static void transitionTopologyState(String topologyName, TMasterCommand topologyStateControlCommand, SchedulerStateManagerAdaptor statemgr, TopologyAPI.TopologyState startState, TopologyAPI.TopologyState expectedState, NetworkUtils.TunnelConfig tunnelConfig) throws TMasterException { TopologyAPI.TopologyState state = TMasterUtils.getRuntimeTopologyState(topologyName, statemgr); if (state == null) { throw new TMasterException(String.format( "Topology '%s' is not initialized yet", topologyName)); } if (state == expectedState) { throw new TMasterException(String.format( "Topology {0} command received topology {1} but already in {2} state", topologyStateControlCommand, topologyName, state)); } if (state != startState) { throw new TMasterException(String.format( "Topology '%s' is not in state '%s'", topologyName, startState)); } TMasterUtils.sendToTMaster( topologyStateControlCommand.name().toLowerCase(), topologyName, statemgr, tunnelConfig); LOG.log(Level.INFO, "Topology command {0} completed successfully.", topologyStateControlCommand); }
Source:
<code>public void test_parallelPrefix$III() { Random rand = new Random(0); int[] list = new int[1000]; for(int i = 0; i < list.length; ++i) { list[i] = rand.nextInt() % 1000; } int begin = 100, end = 500; int[] seqResult = list.clone(); for(int i = begin; i < end - 1; ++i) { seqResult[i + 1] += seqResult[i]; } Arrays.parallelPrefix(list, begin, end, (x, y) -> x + y); assertTrue(Arrays.equals(seqResult, list)); try { Arrays.parallelPrefix(list, begin, end, null); fail(); } catch (NullPointerException expected) { } try { Arrays.parallelPrefix((int[]) null, <START> begin, end, (x, <END> y) -> x + y); fail(); } catch (NullPointerException expected) { } }</code><technical_language>test case > end</technical_language>

Target:
public void test_parallelPrefix$III() { Random rand = new Random(0); int[] list = new int[1000]; for(int i = 0; i < list.length; ++i) { list[i] = rand.nextInt() % 1000; } int begin = 100, end = 500; int[] seqResult = list.clone(); for(int i = begin; i < end - 1; ++i) { seqResult[i + 1] += seqResult[i]; } Arrays.parallelPrefix(list, begin, end, (x, y) -> x + y); assertTrue(Arrays.equals(seqResult, list)); try { Arrays.parallelPrefix(list, begin, end, null); fail(); } catch (NullPointerException expected) { } try { Arrays.parallelPrefix((int[]) null, begin, end, (x, y) -> x + y); fail(); } catch (NullPointerException expected) { } try { Arrays.parallelPrefix(list, end, begin, (x, y) -> x + y); fail(); } catch (IllegalArgumentException expected) { } }
Source:
<code>public void appendAddRecord(final long id, final byte recordType, final EncodingSupport record, final boolean sync, final IOCompletion callback) throws Exception { checkJournalIsLoaded(); lineUpContext(callback); pendingRecords.add(id); Future<?> result = appendExecutor.submit(new Runnable() { @Override public void run() { journalLock.readLock().lock(); try { JournalInternalRecord addRecord = new JournalAddRecord(true, id, recordType, record); JournalFile usedFile = appendRecord(addRecord, false, sync, null, callback); records.put(id, new JournalRecord(usedFile, addRecord.getEncodeSize())); if (logger.isTraceEnabled()) { logger.trace("appendAddRecord::id=" + id + ", userRecordType=" + recordType + ", record = " + record + ", usedFile = " + usedFile); } } catch (Exception e) { <START> ActiveMQJournalLogger.LOGGER.error(e.getMessage(), e); <END> } finally { pendingRecords.remove(id); journalLock.readLock().unlock(); } } }); if (sync && callback == null) { result.get(); } }</code><technical_language>this a concrete method error()</technical_language>

Target:
public void appendAddRecord(final long id, final byte recordType, final EncodingSupport record, final boolean sync, final IOCompletion callback) throws Exception { checkJournalIsLoaded(); lineUpContext(callback); pendingRecords.add(id); final SimpleFuture<Boolean> result = newSyncAndCallbackResult(sync, callback); appendExecutor.execute(new Runnable() { @Override public void run() { journalLock.readLock().lock(); try { JournalInternalRecord addRecord = new JournalAddRecord(true, id, recordType, record); JournalFile usedFile = appendRecord(addRecord, false, sync, null, callback); records.put(id, new JournalRecord(usedFile, addRecord.getEncodeSize())); if (logger.isTraceEnabled()) { logger.trace("appendAddRecord::id=" + id + ", userRecordType=" + recordType + ", record = " + record + ", usedFile = " + usedFile); } if (result != null) { result.set(true); } } catch (Exception e) { if (result != null) { result.fail(e); } logger.error("appendAddRecord::" + e, e); } finally { pendingRecords.remove(id); journalLock.readLock().unlock(); } } }); if (result != null) { result.get(); } }
Source:
<code><R> R tryLock(final K key, final ReturnableDelegate<R> callback, final long time, final TimeUnit unit) throws Throwable { final Lock lock = lockStripes.get(key); if (!lock.tryLock(time, unit)) { <START> String[] threads= new ThreadMonitorTool().getThreads(); <END> Logger.warn(this.getClass(), String.format("Unable to acquire Lock on key %s ", key)); for(String thread: threads) { System.out.println(thread); } throw new DotConcurrentException( String.format("Unable to acquire Lock on key %s ", key) ); } try { return callback.execute(); } finally { lock.unlock(); } }</code><technical_language>Is ok</technical_language>

Target:
<R> R tryLock(final K key, final ReturnableDelegate<R> callback, final long time, final TimeUnit unit) throws Throwable { final Lock lock = lockStripes.get(key); if (!lock.tryLock(time, unit)) { throw new DotConcurrentException( String.format("Unable to acquire Lock on key %s ", key) ); } try { return callback.execute(); } finally { lock.unlock(); } }
Source:
<code>public void run() { <START> decryptJobMetricsTracker.startRequestProcessing(); <END> Exception exception = null; ByteBuffer decryptedBlobContent = null; ByteBuffer decryptedUserMetadata = null; try { Object containerKey = kms.getKey(blobId.getAccountId(), blobId.getContainerId()); Object perBlobKey = cryptoService.decryptKey(encryptedPerBlobKey, containerKey); if (encryptedBlobContent != null) { decryptedBlobContent = cryptoService.decrypt(encryptedBlobContent, perBlobKey); } if (encryptedUserMetadata != null) { decryptedUserMetadata = cryptoService.decrypt(encryptedUserMetadata, perBlobKey); } } catch (Exception e) { exception = e; } finally { decryptJobMetricsTracker.completeRequestProcessing(); callback.onCompletion( exception == null ? new DecryptJobResult(blobId, decryptedBlobContent, decryptedUserMetadata) : null, exception); } }</code><technical_language>if "request" is right term here</technical_language>

Target:
public void run() { decryptJobMetricsTracker.onJobProcessingStart(); Exception exception = null; ByteBuffer decryptedBlobContent = null; ByteBuffer decryptedUserMetadata = null; try { Object containerKey = kms.getKey(blobId.getAccountId(), blobId.getContainerId()); Object perBlobKey = cryptoService.decryptKey(encryptedPerBlobKey, containerKey); if (encryptedBlobContent != null) { decryptedBlobContent = cryptoService.decrypt(encryptedBlobContent, perBlobKey); } if (encryptedUserMetadata != null) { decryptedUserMetadata = cryptoService.decrypt(encryptedUserMetadata, perBlobKey); } } catch (Exception e) { exception = e; } finally { decryptJobMetricsTracker.onJobProcessingComplete(); callback.onCompletion( exception == null ? new DecryptJobResult(blobId, decryptedBlobContent, decryptedUserMetadata) : null, exception); } }
Source:
<code>private String prettyPrintContentWithTimeOut( AsyncPrettyPrinter asyncPrettyPrinter, InputStream in) throws IOException { AsyncPrettyPrintingCallable prettyPrintingCallable = new AsyncPrettyPrintingCallable( in, asyncPrettyPrinter); <START> ExecutorService sExecutorService = AsyncPrettyPrinterExecutorHolder.getExecutorService(); <END> Future<String> future = sExecutorService.submit(prettyPrintingCallable); try { return Util.getUninterruptibly(future, PRETTY_PRINT_TIMEOUT_SEC, TimeUnit.SECONDS); } catch (TimeoutException e) { future.cancel(true); return "Time out after " + PRETTY_PRINT_TIMEOUT_SEC + " seconds of attempting to pretty print\n" + Util.readAsUTF8(in); } catch (ExecutionException e) { Throwable cause = e.getCause(); ExceptionUtil.propagateIfInstanceOf(cause, IOException.class); throw ExceptionUtil.propagate(cause); } }</code><technical_language>executorService this is longer static</technical_language>

Target:
private String prettyPrintContentWithTimeOut( AsyncPrettyPrinter asyncPrettyPrinter, InputStream in) throws IOException { AsyncPrettyPrintingCallable prettyPrintingCallable = new AsyncPrettyPrintingCallable( in, asyncPrettyPrinter); ExecutorService executorService = AsyncPrettyPrinterExecutorHolder.getExecutorService(); if (executorService == null) { return null; } Future<String> future = executorService.submit(prettyPrintingCallable); try { return Util.getUninterruptibly(future, PRETTY_PRINT_TIMEOUT_SEC, TimeUnit.SECONDS); } catch (TimeoutException e) { future.cancel(true); return "Time out after " + PRETTY_PRINT_TIMEOUT_SEC + " seconds of attempting to pretty print\n" + Util.readAsUTF8(in); } catch (ExecutionException e) { Throwable cause = e.getCause(); ExceptionUtil.propagateIfInstanceOf(cause, IOException.class); throw ExceptionUtil.propagate(cause); } }
Source:
<code>public SamReader.Type type() { <START> return SamReader.Type.BAM_TYPE; <END> }</code><technical_language>I if add a new HTSGET type here. Type I of, weird this index extension ".bai"</technical_language>

Target:
public SamReader.Type type() { return SamReader.Type.BAM_HTSGET_TYPE; }
Source:
<code>synchronized public boolean connectOne(long sid, InetSocketAddress electionAddr){ if (senderWorkerMap.get(sid) != null) { LOG.debug("There is a connection already for server " + sid); return true; } Socket sock = null; try { LOG.debug("Opening channel to server " + sid); if (self.isSslQuorum()) { sock = self.getX509Util().createSSLSocket(); <START> } else { <END> sock = new Socket(); } setSockOpts(sock); sock.connect(electionAddr, cnxTO); if (sock instanceof SSLSocket) { ((SSLSocket) sock).startHandshake(); } LOG.debug("Connected to server " + sid); if (quorumSaslAuthEnabled) { initiateConnectionAsync(sock, sid); } else { initiateConnection(sock, sid); } return true; } catch (UnresolvedAddressException e) { LOG.warn("Cannot open channel to " + sid + " at election address " + electionAddr, e); closeSocket(sock); throw e; } catch (X509Exception e) { LOG.warn("Cannot open secure channel to " + sid + " at election address " + electionAddr, e); closeSocket(sock); return false; } catch (IOException e) { LOG.warn("Cannot open channel to " + sid + " at election address " + electionAddr, e); closeSocket(sock); return false; } }</code><technical_language>core of this fix is assigning _sslSock_ _sock_ calling **startHandshake** this in case of error closing properly SSLSocket I correct</technical_language>

Target:
synchronized boolean connectOne(long sid, InetSocketAddress electionAddr){ if (senderWorkerMap.get(sid) != null) { LOG.debug("There is a connection already for server " + sid); return true; } Socket sock = null; try { LOG.debug("Opening channel to server " + sid); if (self.isSslQuorum()) { sock = self.getX509Util().createSSLSocket(); } else { sock = new Socket(); } setSockOpts(sock); sock.connect(electionAddr, cnxTO); if (sock instanceof SSLSocket) { SSLSocket sslSock = (SSLSocket) sock; sslSock.startHandshake(); LOG.info("SSL handshake complete with - - {}", sslSock.getRemoteSocketAddress(), sslSock.getSession().getProtocol(), sslSock.getSession().getCipherSuite()); } LOG.debug("Connected to server " + sid); if (quorumSaslAuthEnabled) { initiateConnectionAsync(sock, sid); } else { initiateConnection(sock, sid); } return true; } catch (UnresolvedAddressException e) { LOG.warn("Cannot open channel to " + sid + " at election address " + electionAddr, e); closeSocket(sock); throw e; } catch (X509Exception e) { LOG.warn("Cannot open secure channel to " + sid + " at election address " + electionAddr, e); closeSocket(sock); return false; } catch (IOException e) { LOG.warn("Cannot open channel to " + sid + " at election address " + electionAddr, e); closeSocket(sock); return false; } }
Source:
<code>protected int decryptMore() throws IOException { if(finalDone) <START> return -1; <END> int n = input.read(inBuffer); if (n < 0) { decryptFinal(); int remaining = outBuffer.remaining(); if (remaining > 0) { return remaining; } return -1; } else if(n == 0) { return 0; } else { decrypt(); return outBuffer.remaining(); } }</code><technical_language>great braces around</technical_language>

Target:
protected int decryptMore() throws IOException { if(finalDone) { return -1; } int n = input.read(inBuffer); if (n < 0) { decryptFinal(); int remaining = outBuffer.remaining(); if (remaining > 0) { return remaining; } return -1; } else if(n == 0) { return 0; } else { decrypt(); return outBuffer.remaining(); } }
Source:
<code>public boolean evaluate(String uriHost, String uriPath, String uriQuery, String httpStatus, String contentType, String userAgent) { <START> return Pageview.isPageview(uriHost.toString(), uriPath.toString(), uriQuery.toString(), httpStatus.toString(), contentType.toString(), userAgent.toString()); <END> }</code><technical_language>uriHost is a String. need call toString() it</technical_language>

Target:
public boolean evaluate( String uriHost, String uriPath, String uriQuery, String httpStatus, String contentType, String userAgent ) { return Pageview.isPageview( uriHost, uriPath, uriQuery, httpStatus, contentType, userAgent ); }
Source:
<code>public static void addLibraryPath(String pathToAdd) { final Field usrPathsField; try { usrPathsField = ClassLoader.class.getDeclaredField("usr_paths"); usrPathsField.setAccessible(true); final String[] paths = (String[]) usrPathsField.get(null); for (String path : paths) { if (path.equals(pathToAdd)) { return; } } final String[] newPaths = Arrays.copyOf(paths, paths.length + 1); newPaths[newPaths.length - 1] = pathToAdd; usrPathsField.set(null, newPaths); for (String x : newPaths) { log.info("New Path " + x); } <START> log.info("Library path " + System.getProperty("java.library.path")); <END> for (String x : (String[]) usrPathsField.get(null)) { log.info("User path " + x); } } catch (NoSuchFieldException | IllegalAccessException e) { throw new RuntimeException("Could not add " + pathToAdd + " to library path", e); } }</code><technical_language>guessing a lot of this is legacy carry over? instead of concatenation. This applies PR, point out individually</technical_language>

Target:
public static void addLibraryPath(String pathToAdd) { final Field usrPathsField; try { usrPathsField = ClassLoader.class.getDeclaredField("usr_paths"); usrPathsField.setAccessible(true); final String[] paths = (String[]) usrPathsField.get(null); for (String path : paths) { if (path.equals(pathToAdd)) { return; } } final String[] newPaths = Arrays.copyOf(paths, paths.length + 1); newPaths[newPaths.length - 1] = pathToAdd; usrPathsField.set(null, newPaths); } catch (NoSuchFieldException | IllegalAccessException e) { throw new RuntimeException("Could not add " + pathToAdd + " to library path", e); } }
Source:
<code>public void updatePartitionWeight(String resourceName, Map<String, Integer> averageWeightMap) { <START> ResourceMonitor monitor = _resourceMonitorMap.get(resourceName); <END> if (monitor == null) { LOG.warn("Failed to update partition weight metric for resource: because resource monitor" + " is not created.", resourceName); return; } monitor.updatePartitionWeightStats(averageWeightMap); }</code><technical_language>getOrCreateResourceMonitor()</technical_language>

Target:
public void updatePartitionWeight(String resourceName, Map<String, Integer> averageWeightMap) { ResourceMonitor monitor = getOrCreateResourceMonitor(resourceName); if (monitor == null) { LOG.warn("Failed to update partition weight metric for resource: because resource monitor" + " is not created.", resourceName); return; } monitor.updatePartitionWeightStats(averageWeightMap); }
Source:
<code>public boolean onMenuItemActionCollapse(MenuItem item) { mMenu.findItem(R.id.menu_new_media).setVisible(true); invalidateOptionsMenu(); enableTabs(true); <START> reloadMediaGrid(); <END> return true; }</code><technical_language>handle search behavior in <LINK_0>, remove this addition changes in respective pull request</technical_language>

Target:
public boolean onMenuItemActionCollapse(MenuItem item) { mMenu.findItem(R.id.menu_new_media).setVisible(true); invalidateOptionsMenu(); enableTabs(true); return true; }
Source:
<code>public void correctNFL() throws IOException { copyNFLFiles(); File descriptorFile = new File(ResourceHelpers.resourceFilePath("nonexistent_image/NFL/nextflow.config")); File jsonFile = new File(ResourceHelpers.resourceFilePath("nextflow_rnatoy/test.json")); String toWrite = "docker-images = " + docker_images; File configPath = createTempFile(toWrite); if (configPath == null) { Assert.fail("Could create temp config file"); } ArrayList<String> args = new ArrayList<String>() {{ <START> add("workflow"); <END> add("launch"); add("--local-entry"); add(descriptorFile.getAbsolutePath()); add("--json"); add(jsonFile.getAbsolutePath()); add("--config"); add(configPath.getAbsolutePath()); }}; Client.main(args.toArray(new String[0])); Assert.assertTrue("Final process status was not success", systemOutRule.getLog().contains("Saving copy of NextFlow stdout to: ")); }</code><technical_language>launch Nextflow workflows this way? @agduncan94 Missed this (might late)</technical_language>

Target:
public void correctNFL() throws IOException { copyNFLFiles(); File descriptorFile = new File(ResourceHelpers.resourceFilePath("nonexistent_image/NFL/nextflow.config")); File jsonFile = new File(ResourceHelpers.resourceFilePath("nextflow_rnatoy/test.json")); String toWrite = "docker-images = " + DOCKER_IMAGE_DIRECTORY; File configPath = createTempFile(toWrite); if (configPath == null) { Assert.fail("Could create temp config file"); } ArrayList<String> args = new ArrayList<String>() {{ add("workflow"); add("launch"); add("--local-entry"); add(descriptorFile.getAbsolutePath()); add("--json"); add(jsonFile.getAbsolutePath()); add("--config"); add(configPath.getAbsolutePath()); }}; Client.main(args.toArray(new String[0])); Assert.assertTrue("Final process status was not success", systemOutRule.getLog().contains("Saving copy of NextFlow stdout to: ")); }
Source:
<code>public TestConfiguration(Class<?> testClass, Method testMethod) { <START> this(testClass, testMethod, Collections.EMPTY_SET); <END> }</code><technical_language>If want better, Collections.emptyList(), is type safe</technical_language>

Target:
public TestConfiguration(Class<?> testClass, Method testMethod) { this(testClass, testMethod, Collections.emptySet()); }
Source:
<code>public TabletIteratorEnvironment(IteratorScope scope, AccumuloConfiguration config) { if (scope == IteratorScope.majc) throw new IllegalArgumentException("must set if compaction is full"); this.scope = scope; this.trm = null; this.config = config; this.fullMajorCompaction = false; this.authorizations = Authorizations.EMPTY; <START> this.topLevelIterators = new ArrayList<SortedKeyValueIterator<Key,Value>>(); <END> }</code><technical_language>Unnecessary SKVI<K,V> parameterization</technical_language>

Target:
public TabletIteratorEnvironment(IteratorScope scope, AccumuloConfiguration config) { if (scope == IteratorScope.majc) throw new IllegalArgumentException("must set if compaction is full"); this.scope = scope; this.trm = null; this.config = config; this.fullMajorCompaction = false; this.authorizations = Authorizations.EMPTY; this.topLevelIterators = new ArrayList<>(); }
Source:
<code>private void createCamelContext() throws Exception { CamelContext camelContext = getContext(); ActiveMQConnectionFactory factory = ActiveMQJMSClient.createConnectionFactory( "(tcp://0.0.0.0:5672,tcp://0.0.0.0:61617)?ha=true;sslEnabled=true;enabledCipherSuites=TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;enabledProtocols=TLSv1.1,TLSv1.2", "name"); if (factory == null) { return; } factory.setRetryInterval(1000); factory.setRetryIntervalMultiplier(1.0); <START> factory.setReconnectAttempts(-1); <END> SjmsComponent sjms = new SjmsComponent(); ConnectionFactoryResource connectionResource = new ConnectionFactoryResource(1, factory, "admin", "admin"); sjms.setConnectionResource(connectionResource); camelContext.addComponent("sjms", sjms); }</code><technical_language>log here</technical_language>

Target:
private void createCamelContext() throws Exception { CamelContext camelContext = getContext(); ActiveMQConnectionFactory factory = ActiveMQJMSClient.createConnectionFactory( "(tcp://0.0.0.0:5672,tcp://0.0.0.0:61617)?ha=true;sslEnabled=true;enabledCipherSuites=TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;enabledProtocols=TLSv1.1,TLSv1.2", "name"); if (factory == null) { LOGGER.debug("Could not create ActiveMQConnectionFactory"); return; } factory.setRetryInterval(1000); factory.setRetryIntervalMultiplier(1.0); factory.setReconnectAttempts(-1); SjmsComponent sjms = new SjmsComponent(); ConnectionFactoryResource connectionResource = new ConnectionFactoryResource(1, factory, "admin", "admin"); sjms.setConnectionResource(connectionResource); camelContext.addComponent("sjms", sjms); }
Source:
<code><START> public Integer getPulseTickSpeed(GlowBlock block) { <END> return null; }</code><technical_language>Integer int</technical_language>

Target:
public int getPulseTickSpeed(GlowBlock block) { return 0; }
Source:
<code>private static boolean hasJavadoc(DetailAST ast) { final boolean hasBefore = ast.getPreviousSibling() != null && isJavadoc(ast.getPreviousSibling()); final Optional<DetailAST> firstAnnotationChild = Optional.of(ast.getFirstChild()) .map(DetailAST::getFirstChild) .map(DetailAST::getFirstChild); boolean hasWithAnnotation = false; if (firstAnnotationChild.isPresent()) { for (DetailAST child = firstAnnotationChild.get(); child != null; child = child.getNextSibling()) { if (isJavadoc(child)) { hasWithAnnotation = true; break; } } } return hasBefore || hasWithAnnotation; <START> } <END></code><technical_language>do need execute this IF block if hasBefore is true. Please refactor code</technical_language>

Target:
private static boolean hasJavadoc(DetailAST ast) { final boolean hasJavadocBefore = ast.getPreviousSibling() != null && isJavadoc(ast.getPreviousSibling()); return hasJavadocBefore || hasJavadocAboveAnnotation(ast); }
Source:
<code>public void build() { Flyway flyway = new Flyway(); flyway.setDataSource(properties.getProperty("databaseUrl"), properties.getProperty("databaseUrl") ,properties.getProperty("databaseUrl")); <START> flyway.setInitVersion("0"); <END> flyway.setTarget(MigrationVersion.fromVersion("0.3")); flyway.clean(); flyway.init(); flyway.migrate(); }</code><technical_language>This error</technical_language>

Target:
public void build() { Flyway flyway = new Flyway(); flyway.setDataSource(properties.getProperty("databaseUrl"), properties.getProperty("databaseUsername") ,properties.getProperty("databasePassword")); flyway.setInitVersion("0"); flyway.setTarget(MigrationVersion.fromVersion("0.3")); flyway.clean(); flyway.init(); flyway.migrate(); }
Source:
<code>private static char[] getManifestContents(IPath jarPath) throws CoreException, IOException { if (JavaIndex.isEnabled()) { JavaIndex index = JavaIndex.getIndex(); String location = JavaModelManager.getLocalFile(jarPath).getAbsolutePath(); try (IReader reader = index.getNd().acquireReadLock()) { NdResourceFile resourceFile = index.getResourceFile(location.toCharArray()); if (index.isUpToDate(resourceFile)) { char[] manifestContent = resourceFile.getManifestContent().getChars(); if (manifestContent.length == 0) { return null; } return manifestContent; } } } ZipFile zip = null; InputStream inputStream = null; JavaModelManager manager = JavaModelManager.getJavaModelManager(); try { zip = manager.getZipFile(jarPath); ZipEntry manifest = zip.getEntry("META-INF/MANIFEST.MF"); if (manifest == null) { return null; } inputStream = zip.getInputStream(manifest); char[] chars = <START> org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsCharArray(inputStream, <END> -1, org.eclipse.jdt.internal.compiler.util.Util.UTF_8); return chars; } finally { if (inputStream != null) { try { inputStream.close(); } catch (IOException e) { } } manager.closeZipFile(zip); } }</code><technical_language>more readable static import</technical_language>

Target:
private static char[] getManifestContents(IPath jarPath) throws CoreException, IOException { if (JavaIndex.isEnabled()) { JavaIndex index = JavaIndex.getIndex(); String location = JavaModelManager.getLocalFile(jarPath).getAbsolutePath(); try (IReader reader = index.getNd().acquireReadLock()) { NdResourceFile resourceFile = index.getResourceFile(location.toCharArray()); if (index.isUpToDate(resourceFile)) { char[] manifestContent = resourceFile.getManifestContent().getChars(); if (manifestContent.length == 0) { return null; } return manifestContent; } } } ZipFile zip = null; InputStream inputStream = null; JavaModelManager manager = JavaModelManager.getJavaModelManager(); try { zip = manager.getZipFile(jarPath); ZipEntry manifest = zip.getEntry("META-INF/MANIFEST.MF"); if (manifest == null) { return null; } inputStream = zip.getInputStream(manifest); char[] chars = getInputStreamAsCharArray(inputStream, -1, UTF_8); return chars; } finally { if (inputStream != null) { try { inputStream.close(); } catch (IOException e) { } } manager.closeZipFile(zip); } }