auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public static Block distinct(@TypeParameter("E") Type type, @SqlType("array(E)") Block array) { int arrayLength = array.getPositionCount(); if (arrayLength < 2) { return array; } if (arrayLength == 2) { if (TypeUtils.positionEqualsPosition(type, array, 0, array, 1)) { return array.getSingleValueBlock(0); } else { return array; } } TypedSet typedSet = new TypedSet(type, arrayLength, "array_distinct"); BlockBuilder distinctElementBlockBuilder; int position = 0; if (array.mayHaveNull()) { while (position < arrayLength && typedSet.add(array, position)) { position++; } if (position == arrayLength) { return array; } distinctElementBlockBuilder = type.createBlockBuilder(null, arrayLength); for (int i = 0; i < position; i++) { type.appendTo(array, i, distinctElementBlockBuilder); } for (position++; position < arrayLength; position++) { if (typedSet.add(array, position)) { type.appendTo(array, position, distinctElementBlockBuilder); } } } else { while (position < arrayLength && typedSet.addNonNull(array, position)) { position++; } if (position == arrayLength) { return array; } distinctElementBlockBuilder = type.createBlockBuilder(null, arrayLength); for (int i = 0; i < position; i++) { type.appendTo(array, i, distinctElementBlockBuilder); } for (position++; position < arrayLength; position++) { if (typedSet.addNonNull(array, position)) { type.appendTo(array, position, distinctElementBlockBuilder); } } } return distinctElementBlockBuilder.build(); }

Target:
public static Block distinct(@TypeParameter("E") Type type, @SqlType("array(E)") Block array) { int arrayLength = array.getPositionCount(); if (arrayLength < 2) { return array; } if (arrayLength == 2) { if (TypeUtils.positionEqualsPosition(type, array, 0, array, 1)) { return array.getSingleValueBlock(0); } else { return array; } } TypedSet typedSet = new TypedSet(type, arrayLength, "array_distinct"); BlockBuilder distinctElementBlockBuilder; if (array.mayHaveNull()) { int firstDuplicatePosition = 0; while (firstDuplicatePosition < arrayLength && typedSet.add(array, firstDuplicatePosition)) { firstDuplicatePosition++; } if (firstDuplicatePosition == arrayLength) { return array; } int position = 0; distinctElementBlockBuilder = type.createBlockBuilder(null, arrayLength); while (position < firstDuplicatePosition) { type.appendTo(array, position, distinctElementBlockBuilder); position++; } while (position < arrayLength) { if (typedSet.add(array, position)) { type.appendTo(array, position, distinctElementBlockBuilder); } position++; } } else { int firstDuplicatePosition = 0; while (firstDuplicatePosition < arrayLength && typedSet.addNonNull(array, firstDuplicatePosition)) { firstDuplicatePosition++; } if (firstDuplicatePosition == arrayLength) { return array; } int position = 0; distinctElementBlockBuilder = type.createBlockBuilder(null, arrayLength); while (position < firstDuplicatePosition) { type.appendTo(array, position, distinctElementBlockBuilder); position++; } while (position < arrayLength) { if (typedSet.addNonNull(array, position)) { type.appendTo(array, position, distinctElementBlockBuilder); } position++; } } return distinctElementBlockBuilder.build(); }
Source:
public void downloadBlobStatus(HttpServletRequest request, HttpServletResponse response, String key, String reason) throws IOException { TransientStore ts = Framework.getService(TransientStoreService.class).getStore(STORE_NAME); try { if (!ts.exists(key)) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return; } List<Blob> blobs = ts.getBlobs(key); if (blobs == null || blobs.isEmpty()) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return; } if (blobs.size() > 1) { throw new IllegalArgumentException("multipart download not yet implemented"); } if (ts.getParameter(key, ERROR) != null) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ((Throwable) ts.getParameter(key, ERROR)).getMessage()); } else { AsyncBlob blob = null; if (ts.isCompleted(key)) { blob = new AsyncBlob(key, true, 100); } else { Serializable progress = ts.getParameter(key, PROGRESS); blob = new AsyncBlob(key, false, progress != null ? (int) progress : -1); } downloadBlob(request, response, null, null, blob, blob.getFilename(), reason); } } finally { } }

Target:
public void downloadBlobStatus(HttpServletRequest request, HttpServletResponse response, String key, String reason) throws IOException { this.downloadBlob(request, response, key, reason, true); }
Source:
private void determineApiTypes() { collectedTypes.stream(). map(ClassTypeInfo::getRaw). flatMap(Helper.instanceOf(ClassTypeInfo.class)). filter(t -> !t.getPackageName().equals(ifaceFQCN)). forEach(importedTypes::add); collectedTypes.stream(). map(ClassTypeInfo::getRaw). flatMap(Helper.instanceOf(ApiTypeInfo.class)). filter(t -> !t.equals(type.getRaw())). forEach(referencedTypes::add); collectedTypes.stream(). map(ClassTypeInfo::getRaw). flatMap(Helper.instanceOf(ClassTypeInfo.class)). filter(t -> t.getKind() == ClassKind.DATA_OBJECT). forEach(referencedDataObjectTypes::add); collectedTypes.stream(). map(ClassTypeInfo::getRaw). flatMap(Helper.instanceOf(EnumTypeInfo.class)). filter(t -> t.getKind() == ClassKind.ENUM). forEach(referencedEnumTypes::add); }

Target:
private void determineApiTypes() { importedTypes = collectedTypes.stream(). map(ClassTypeInfo::getRaw). flatMap(Helper.instanceOf(ClassTypeInfo.class)). filter(t -> !t.getPackageName().equals(ifaceFQCN)). collect(Collectors.toSet()); referencedTypes = collectedTypes.stream(). map(ClassTypeInfo::getRaw). flatMap(Helper.instanceOf(ApiTypeInfo.class)). filter(t -> !t.equals(type.getRaw())). collect(Collectors.toSet()); referencedDataObjectTypes = collectedTypes.stream(). map(ClassTypeInfo::getRaw). flatMap(Helper.instanceOf(ClassTypeInfo.class)). filter(t -> t.getKind() == ClassKind.DATA_OBJECT). collect(Collectors.toSet()); referencedEnumTypes = collectedTypes.stream(). map(ClassTypeInfo::getRaw). flatMap(Helper.instanceOf(EnumTypeInfo.class)). filter(t -> t.getKind() == ClassKind.ENUM). collect(Collectors.toSet()); }
Source:
protected ISchedulingRule getEnabledStateSchedulingRule(IDebugCommandRequest request) { return new ExclusiveRule(); }

Target:
protected ISchedulingRule getEnabledStateSchedulingRule(IDebugCommandRequest request) { return exclusiveRule; }
Source:
public void fill(Menu menu, int index) { HashMap<String, Boolean> isSheetEmptyMap = OfficeView.getOpenedView().getIsSheetEmptyMap(); for (String sheetName : isSheetEmptyMap.keySet()) { MenuItem menuItem = new MenuItem(menu, SWT.CHECK, index); menuItem.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { OfficeView.getOpenedView().selectSheet(menuItem.getText()); } @Override public void widgetDefaultSelected(SelectionEvent e) { OfficeView.getOpenedView().selectSheet(menuItem.getText()); } }); if (OfficeView.getOpenedView().getSelectedSheetName().contentEquals(sheetName)) menuItem.setSelection(true); if (isSheetEmptyMap.get(sheetName)) menuItem.setText(sheetName); else { menuItem.setText(sheetName + " (Empty)"); menuItem.setEnabled(false); } } }

Target:
public void fill(Menu menu, int index) { HashMap<String, Boolean> isSheetEmptyMap = OfficeView.getOpenedView().getIsSheetEmptyMap(); if (isSheetEmptyMap == null) return; for (String sheetName : isSheetEmptyMap.keySet()) { MenuItem menuItem = new MenuItem(menu, SWT.CHECK, index); menuItem.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { OfficeView.getOpenedView().selectSheet(menuItem.getText()); } @Override public void widgetDefaultSelected(SelectionEvent e) { OfficeView.getOpenedView().selectSheet(menuItem.getText()); } }); if (OfficeView.getOpenedView().getSelectedSheetName().contentEquals(sheetName)) menuItem.setSelection(true); if (isSheetEmptyMap.get(sheetName)) menuItem.setText(sheetName); else { menuItem.setText(sheetName + " (Empty)"); menuItem.setEnabled(false); } } }
Source:
public static PartitionDesc buildPartitionDesc(String partitionName) { PartitionDesc partitionDesc = new PartitionDesc(); partitionDesc.setPartitionName(partitionName); String[] partitionNames = partitionName.split("/"); List<PartitionKeyProto> partitionKeyList = new ArrayList<>(); for (String partitionName1 : partitionNames) { String[] splits = partitionName1.split("="); String columnName = "", partitionValue = ""; if (splits.length == 2) { columnName = splits[0]; partitionValue = splits[1]; } else if (splits.length == 1) { if (partitionName1.charAt(0) == '=') { partitionValue = splits[0]; } else { columnName = ""; } } PartitionKeyProto.Builder builder = PartitionKeyProto.newBuilder(); builder.setColumnName(columnName); builder.setPartitionValue(partitionValue); partitionKeyList.add(builder.build()); } partitionDesc.setPartitionKeys(partitionKeyList); partitionDesc.setPath("hdfs://xxx.com/warehouse/" + partitionName); return partitionDesc; }

Target:
public static PartitionDesc buildPartitionDesc(String partitionName) { PartitionDesc partitionDesc = new PartitionDesc(); partitionDesc.setPartitionName(partitionName); String[] partitionNames = partitionName.split("/"); List<PartitionKeyProto> partitionKeyList = new ArrayList<>(); for (String partition : partitionNames) { String[] splits = partition.split("="); String columnName = "", partitionValue = ""; if (splits.length == 2) { columnName = splits[0]; partitionValue = splits[1]; } else if (splits.length == 1) { if (partition.charAt(0) == '=') { partitionValue = splits[0]; } else { columnName = ""; } } PartitionKeyProto.Builder builder = PartitionKeyProto.newBuilder(); builder.setColumnName(columnName); builder.setPartitionValue(partitionValue); partitionKeyList.add(builder.build()); } partitionDesc.setPartitionKeys(partitionKeyList); partitionDesc.setPath("hdfs://xxx.com/warehouse/" + partitionName); return partitionDesc; }
Source:
private void testBoundedTextFileSource(FailoverType failoverType) throws Exception { final File testDir = TMP_FOLDER.newFolder(); writeAllFiles(testDir); writeHiddenJunkFiles(testDir); final FileSource<String> source = FileSource .forRecordStreamFormat(new TextLineFormat(), Path.fromLocalFile(testDir)) .build(); final StreamExecutionEnvironment env = new TestStreamEnvironment(miniCluster, PARALLELISM); env.setParallelism(PARALLELISM); env.enableCheckpointing(10L); final DataStream<String> stream = env.fromSource( source, WatermarkStrategy.noWatermarks(), "file-source"); final DataStream<String> streamFailingInTheMiddleOfReading = RecordCounterToFail.wrapWithFailureAfter(stream, LINES.length / 2); final ClientAndIterator<String> client = DataStreamUtils.collectWithClient( streamFailingInTheMiddleOfReading, "Bounded TextFiles Test"); final JobID jobId = client.client.getJobID(); RecordCounterToFail.waitToFail(); triggerFailover(failoverType, jobId, RecordCounterToFail::continueProcessing); final List<String> result = new ArrayList<>(); while (client.iterator.hasNext()) { result.add(client.iterator.next()); } verifyResult(result); }

Target:
private void testBoundedTextFileSource(FailoverType failoverType) throws Exception { final File testDir = TMP_FOLDER.newFolder(); writeAllFiles(testDir); writeHiddenJunkFiles(testDir); final FileSource<String> source = FileSource .forRecordStreamFormat(new TextLineFormat(), Path.fromLocalFile(testDir)) .build(); final StreamExecutionEnvironment env = new TestStreamEnvironment(miniCluster, PARALLELISM); env.setParallelism(PARALLELISM); final DataStream<String> stream = env.fromSource( source, WatermarkStrategy.noWatermarks(), "file-source"); final DataStream<String> streamFailingInTheMiddleOfReading = RecordCounterToFail.wrapWithFailureAfter(stream, LINES.length / 2); final ClientAndIterator<String> client = DataStreamUtils.collectWithClient( streamFailingInTheMiddleOfReading, "Bounded TextFiles Test"); final JobID jobId = client.client.getJobID(); RecordCounterToFail.waitToFail(); triggerFailover(failoverType, jobId, RecordCounterToFail::continueProcessing); final List<String> result = new ArrayList<>(); while (client.iterator.hasNext()) { result.add(client.iterator.next()); } verifyResult(result); }
Source:
public static KeyWrapper getClientPublicKeyWrapper(KeycloakSession session, ClientModel client, JWSInput input) { String kid = input.getHeader().getKeyId(); PublicKey verifyKey = getClientPublicKey(session, client, input); if (verifyKey == null) return null; KeyWrapper keyWrapper = new KeyWrapper(); keyWrapper.setKid(kid); keyWrapper.setAlgorithm(input.getHeader().getAlgorithm().name()); keyWrapper.setVerifyKey(verifyKey); return keyWrapper; }

Target:
public static KeyWrapper getClientPublicKeyWrapper(KeycloakSession session, ClientModel client, JWSInput input) { String kid = input.getHeader().getKeyId(); PublicKeyStorageProvider keyStorage = session.getProvider(PublicKeyStorageProvider.class); String modelKey = PublicKeyStorageUtils.getClientModelCacheKey(client.getRealm().getId(), client.getId()); ClientPublicKeyLoader loader = new ClientPublicKeyLoader(session, client); return keyStorage.getPublicKey(modelKey, kid, loader); }
Source:
List<Map<String, Object>> getNetworkInterfaces(VM vm){ Map<String, Object> resultMap = new HashMap(); List<String> inet6Adsreess = new ArrayList<>(); List<String> inet4Adsress = new ArrayList<>(); List<Map<String, Object>> nets = new ArrayList<>(); resultMap.put("name", "eth0"); inet6Adsreess.add("fe80::21a:4aff:fe16:2016"); inet6Adsreess.add("2620:52:0:2380:21a:4aff:fe16:2016"); resultMap.put("inet6", inet6Adsreess); inet4Adsress.add(vm.getIp()); resultMap.put("inet", inet4Adsress); resultMap.put("hw", vm.getMacAddress()); nets.add(resultMap); log.debug("network list is {}", nets.toString()); return nets; }

Target:
List<Map<String, Object>> getNetworkInterfaces(VM vm){ Map<String, Object> resultMap = new HashMap(); List<String> inet6Addresses = new ArrayList<>(); List<String> inet4Addresses = new ArrayList<>(); List<Map<String, Object>> nets = new ArrayList<>(); resultMap.put("name", "eth0"); inet6Addresses.add("fe80::21a:4aff:fe16:2016"); inet6Addresses.add("2620:52:0:2380:21a:4aff:fe16:2016"); resultMap.put("inet6", inet6Addresses); inet4Addresses.add(vm.getIp()); resultMap.put("inet", inet4Addresses); resultMap.put("hw", vm.getMacAddress()); nets.add(resultMap); log.debug("network list is {}", nets.toString()); return nets; }
Source:
public void endVisit(@Nonnull JMethodCall call) { Collection<JMethod> targets = call.getMethodId().getMethods(); if (targets.size() != 1) { return; } JMethod target = targets.iterator().next(); if (target.isAbstract() || target.isNative()) { return; } List<JAnnotation> annotationList = target.getAnnotations(forceInlineAnnotationType); if (annotationList.isEmpty()) { return; } call.addMarker(new InlineMarker(target)); return; }

Target:
public void endVisit(@Nonnull JMethodCall call) { Collection<JMethod> targets = call.getMethodId().getMethods(); if (targets.size() != 1) { return; } JMethod target = targets.iterator().next(); if (target.isAbstract() || target.isNative()) { return; } Location location = target.getEnclosingType().getLocation(); if (location instanceof TypeInInputLibraryLocation) { InputLibrary inputLibrary = ((TypeInInputLibraryLocation) location).getInputLibrary(); if (inputLibrary.containsFileType(FileType.PREBUILT)) { return; } } List<JAnnotation> annotationList = target.getAnnotations(forceInlineAnnotationType); if (!annotationList.isEmpty()) { call.addMarker(new InlineMarker(target)); } }
Source:
public static boolean isModifiedEtag(HttpServletRequest request, HttpServletResponse response,String assetId, long _lastModified, long fileSize) { int _daysCache = Config.getIntProperty("asset.cache.control.max.days", 30); GregorianCalendar expiration = new GregorianCalendar(); expiration.add(java.util.Calendar.DAY_OF_MONTH, _daysCache); int seconds = (_daysCache * 24 * 60 * 60); if(_lastModified < 0) { _lastModified = 0; } _lastModified = _lastModified / 1000; _lastModified = _lastModified * 1000; Date _lastModifiedDate = new java.util.Date(_lastModified); String _eTag = "dot:" + assetId + ":" + _lastModified + ":" + fileSize; response.setHeader("Expires", httpDate.get().format(expiration.getTime())); if (!response.containsHeader(HttpHeaders.CACHE_CONTROL)) { response.setHeader(HttpHeaders.CACHE_CONTROL, "public, max-age=" + seconds); } String ifModifiedSince = request.getHeader("If-Modified-Since"); String ifNoneMatch = request.getHeader("If-None-Match"); if(ifNoneMatch != null){ if(_eTag.equals(ifNoneMatch) || ifNoneMatch.equals("*")){ response.setStatus(HttpServletResponse.SC_NOT_MODIFIED ); return false; } } if(ifModifiedSince != null){ try{ Date ifModifiedSinceDate = httpDate.get().parse(ifModifiedSince); if(_lastModifiedDate.getTime() <= ifModifiedSinceDate.getTime()){ response.setStatus(HttpServletResponse.SC_NOT_MODIFIED ); return false; } } catch(Exception e){} } response.setHeader("Last-Modified", httpDate.get().format(_lastModifiedDate)); response.setHeader("ETag", _eTag); return true; }

Target:
public static boolean isModifiedEtag(HttpServletRequest request, HttpServletResponse response,String assetId, long _lastModified, long fileSize) { int _daysCache = Config.getIntProperty("asset.cache.control.max.days", 30); GregorianCalendar expiration = new GregorianCalendar(); expiration.add(java.util.Calendar.DAY_OF_MONTH, _daysCache); int seconds = (_daysCache * 24 * 60 * 60); if(_lastModified < 0) { _lastModified = 0; } _lastModified = _lastModified / 1000; _lastModified = _lastModified * 1000; Date _lastModifiedDate = new java.util.Date(_lastModified); String _eTag = "dot:" + assetId + ":" + _lastModified + ":" + fileSize; if (!response.containsHeader(EXPIRES)) { response.setHeader(EXPIRES, httpDate.get().format(expiration.getTime())); } if (!response.containsHeader(CACHE_CONTROL)) { response.setHeader(CACHE_CONTROL, "public, max-age=" + seconds); } String ifModifiedSince = request.getHeader("If-Modified-Since"); String ifNoneMatch = request.getHeader("If-None-Match"); if(ifNoneMatch != null){ if(_eTag.equals(ifNoneMatch) || ifNoneMatch.equals("*")){ response.setStatus(HttpServletResponse.SC_NOT_MODIFIED ); return false; } } if(ifModifiedSince != null){ try{ Date ifModifiedSinceDate = httpDate.get().parse(ifModifiedSince); if(_lastModifiedDate.getTime() <= ifModifiedSinceDate.getTime()){ response.setStatus(HttpServletResponse.SC_NOT_MODIFIED ); return false; } } catch(Exception e){} } response.setHeader("Last-Modified", httpDate.get().format(_lastModifiedDate)); response.setHeader("ETag", _eTag); return true; }
Source:
public void allBindingsChanged(BindingProvider provider) { logger.debug("allBindingsChanged()"); logger.debug("Provider items count: {}", provider.getItemNames().size()); itemUpdateDisabled = true; if (provider.getItemNames().size() > 0) { triggerItemsUpdate = true; } itemCount = provider.getItemNames().size(); super.allBindingsChanged(provider); }

Target:
public void allBindingsChanged(BindingProvider provider) { logger.debug("allBindingsChanged(): Provider items count: {}", provider.getItemNames().size()); itemUpdateDisabled = true; if (provider.getItemNames().size() > 0) { triggerItemsUpdate = true; } itemCount = provider.getItemNames().size(); super.allBindingsChanged(provider); }
Source:
void indexRedirectsToOverview() throws Exception { perform(get("/")) .andExpect(status().isFound()) .andExpect(header().string("Location", "/web/overview")); }

Target:
void indexRedirectsToOverview() throws Exception { perform(get("/")) .andExpect(status().isFound()) .andExpect(redirectedUrl("/web/overview")); }
Source:
private Status check() { if (mJobId == null) { return Status.FAILED; } JobInfo jobInfo; try { jobInfo = mClient.getJobStatus(mJobId); } catch (IOException e) { LOG.warn("Failed to get status for job (jobId={})", mJobId, e); return Status.FAILED; } boolean finished = true; for (JobInfo child : jobInfo.getChildren()) { if (!child.getStatus().isFinished()) { finished = false; break; } } if (finished) { if (jobInfo.getStatus().equals(Status.FAILED)) { System.out.println(String.format("Attempt %s to load %s failed because: %s", mRetryPolicy.getAttemptCount(), mJobConfig.getFilePath(), jobInfo.getErrorMessage())); } else if (jobInfo.getStatus().equals(Status.COMPLETED)) { System.out.println(String.format("Attempt %s to load %s completed", mRetryPolicy.getAttemptCount(), mJobConfig.getFilePath())); } return jobInfo.getStatus(); } return Status.RUNNING; }

Target:
private Status check() { if (mJobId == null) { return Status.FAILED; } JobInfo jobInfo; try { jobInfo = mClient.getJobStatus(mJobId); } catch (IOException e) { LOG.warn("Failed to get status for job (jobId={})", mJobId, e); return Status.FAILED; } boolean finished = true; for (JobInfo child : jobInfo.getChildren()) { if (!child.getStatus().isFinished()) { finished = false; break; } } if (finished) { if (jobInfo.getStatus().equals(Status.FAILED)) { System.out.println(String.format("Attempt %d to load %s failed because: %s", mRetryPolicy.getAttemptCount(), mJobConfig.getFilePath(), jobInfo.getErrorMessage())); } else if (jobInfo.getStatus().equals(Status.COMPLETED)) { System.out.println(String.format("Successfully loaded path %s after %d attempts", mJobConfig.getFilePath(), mRetryPolicy.getAttemptCount())); } return jobInfo.getStatus(); } return Status.RUNNING; }
Source:
private void hideDangerousDeveloperPrefsIfNeeded() { if (!GlobalPrivilegesManager.isAdvancedSettingsAccessEnabled() && !BuildConfig.DEBUG) { PreferenceScreen prefScreen = getPreferenceScreen(); for (String key : getNonWhitelistedKeys()) { Preference pref = findPreference(key); if (pref != null) { prefScreen.removePreference(pref); } } } }

Target:
private void hideDangerousDeveloperPrefsIfNeeded() { if (!GlobalPrivilegesManager.isAdvancedSettingsAccessEnabled() && !BuildConfig.DEBUG) { PreferenceScreen prefScreen = getPreferenceScreen(); for (int i = 0; i < prefScreen.getPreferenceCount(); i++) { Preference pref = prefScreen.getPreference(i); if (pref != null && !WHITELISTED_DEVELOPER_PREF_KEYS.contains(pref.getKey())) { prefScreen.removePreference(pref); } } } }
Source:
public void onBackPressed() { if (contributionsFragment != null && activeFragment == ActiveFragment.CONTRIBUTIONS) { if (ContributionsFragment.mediaDetailPagerFragment==null) { super.onBackPressed(); } else if (ContributionsFragment.mediaDetailPagerFragment!=null) { if(!ContributionsFragment.mediaDetailPagerFragment.isVisible()){ super.onBackPressed(); } else { contributionsFragment.backButtonClicked(); } } } else if (nearbyParentFragment != null && activeFragment == ActiveFragment.NEARBY) { nearbyParentFragment.backButtonClicked(); } else if (exploreFragment != null && activeFragment == ActiveFragment.EXPLORE) { exploreFragment.onBackPressed(); } else if (bookmarkFragment != null && activeFragment == ActiveFragment.BOOKMARK) { bookmarkFragment.onBackPressed(); } else { super.onBackPressed(); } }

Target:
public void onBackPressed() { if (contributionsFragment != null && activeFragment == ActiveFragment.CONTRIBUTIONS) { mediaDetailPagerFragment=contributionsFragment.getMediaDetailPagerFragment(); if (mediaDetailPagerFragment ==null) { super.onBackPressed(); } else if (mediaDetailPagerFragment!=null) { if(!mediaDetailPagerFragment.isVisible()){ super.onBackPressed(); } else { contributionsFragment.backButtonClicked(); } } } else if (nearbyParentFragment != null && activeFragment == ActiveFragment.NEARBY) { nearbyParentFragment.backButtonClicked(); } else if (exploreFragment != null && activeFragment == ActiveFragment.EXPLORE) { exploreFragment.onBackPressed(); } else if (bookmarkFragment != null && activeFragment == ActiveFragment.BOOKMARK) { bookmarkFragment.onBackPressed(); } else { super.onBackPressed(); } }
Source:
public void test() { NestedGenericClass<List<Object>> nestedGenericClass = new NestedGenericClass<List<Object>>(new java.util.ArrayList<Object>()); nestedGenericClass.genericMethod(new java.util.LinkedList<Object>()); ComplexNestedGenericClass<List<Object>> complexNestedGenericClass = new ComplexNestedGenericClass<List<Object>>(new java.util.ArrayList<Object>()); complexNestedGenericClass.complexGenericMethod(new java.util.LinkedList<Object>()); }

Target:
public void test() { NestedGenericClass<List<Object>> nestedGenericClass = new NestedGenericClass<List<Object>>(new java.util.ArrayList<Object>()); nestedGenericClass.genericMethod(new java.util.LinkedList<Object>()); ComplexNestedGenericClass<List<Object>> complexNestedGenericClass = new ComplexNestedGenericClass<List<Object>>(new java.util.ArrayList<Object>()); complexNestedGenericClass.complexGenericMethod(new java.util.LinkedList<Object>()); ComplexNestedGenericClass v1 = new ComplexNestedGenericClass(new java.util.ArrayList<Object>()); ComplexNestedGenericClass<U> v2 = new ComplexNestedGenericClass<U>(new U()); ComplexNestedGenericClass<? extends List<Object>> v3 = new ComplexNestedGenericClass<List<Object>>(new java.util.ArrayList<Object>()); }
Source:
public void itemWriterForPojos() throws Exception { AvroItemWriter avroItemWriter = new AvroItemWriter(output,plainOldUserSchemaResource, PlainOldUser.class); avroItemWriter.afterPropertiesSet(); avroItemWriter.open(new ExecutionContext()); avroItemWriter.write(this.plainOldUsers()); avroItemWriter.close(); verifyRecordsWithEmbeddedHeader(outputStream.toByteArray(), this.plainOldUsers(), PlainOldUser.class); }

Target:
public void itemWriterForPojos() throws Exception { AvroItemWriter<PlainOldUser> avroItemWriter = new AvroItemWriter(output,plainOldUserSchemaResource, PlainOldUser.class); avroItemWriter.open(new ExecutionContext()); avroItemWriter.write(this.plainOldUsers()); avroItemWriter.close(); verifyRecordsWithEmbeddedHeader(outputStream.toByteArray(), this.plainOldUsers(), PlainOldUser.class); }
Source:
private void testAutoServer(boolean port) throws Exception { if (config.memory || config.networked) { return; } deleteDb(getTestName()); String url = getURL(getTestName() + ";AUTO_SERVER=TRUE", true); if (port) { url += ";AUTO_SERVER_PORT=11111"; } String user = getUser(), password = getPassword(); Connection connServer = getConnection(url + ";OPEN_NEW=TRUE", user, password); int i = ITERATIONS; for (; i > 0; i--) { Thread.sleep(100); SortedProperties prop = SortedProperties.loadProperties( getBaseDir() + "/" + getTestName() + ".lock.db"); String key = prop.getProperty("id"); String server = prop.getProperty("server"); if (server != null) { String u2 = url.substring(url.indexOf(';')); u2 = "jdbc:h2:tcp://" + server + "/" + key + u2; Connection conn = DriverManager.getConnection(u2, user, password); conn.close(); int gotPort = Integer.parseInt(server.substring(server.lastIndexOf(':') + 1)); if (port) { assertEquals(11111, gotPort); } break; } } if (i <= 0) { fail(); } try (Connection conn = getConnection(url + ";OPEN_NEW=TRUE")) { Statement stat = conn.createStatement(); if (config.big) { try { stat.execute("SHUTDOWN"); } catch (SQLException e) { assertKnownException(e); } } } connServer.close(); deleteDb("autoServer"); }

Target:
private void testAutoServer(boolean port) throws Exception { if (config.memory || config.networked) { return; } deleteDb(getTestName()); String url = getURL(getTestName() + ";AUTO_SERVER=TRUE", true); if (port) { url += ";AUTO_SERVER_PORT=11111"; } String user = getUser(), password = getPassword(); try (Connection connServer = getConnection(url + ";OPEN_NEW=TRUE", user, password)) { int i = ITERATIONS; for (; i > 0; i--) { Thread.sleep(100); SortedProperties prop = SortedProperties.loadProperties( getBaseDir() + "/" + getTestName() + ".lock.db"); String key = prop.getProperty("id"); String server = prop.getProperty("server"); if (server != null) { String u2 = url.substring(url.indexOf(';')); u2 = "jdbc:h2:tcp://" + server + "/" + key + u2; Connection conn = DriverManager.getConnection(u2, user, password); conn.close(); int gotPort = Integer.parseInt(server.substring(server.lastIndexOf(':') + 1)); if (port) { assertEquals(11111, gotPort); } break; } } if (i <= 0) { fail(); } try (Connection conn = getConnection(url + ";OPEN_NEW=TRUE")) { Statement stat = conn.createStatement(); if (config.big) { try { stat.execute("SHUTDOWN"); } catch (SQLException e) { assertKnownException(e); } } } } deleteDb("autoServer"); }
Source:
public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = View.inflate(getContext(), R.layout.contributor_item, null); ViewHolder viewHolder = new ViewHolder(); viewHolder.contributorName = (TextView) convertView.findViewById(R.id.contributorName); viewHolder.contributorAvatar = (ImageView) convertView.findViewById(R.id.contributorIcon); convertView.setTag(viewHolder); } Contributor contributor = getItem(position); ViewHolder viewHolder = (ViewHolder) convertView.getTag(); viewHolder.contributorName.setText(contributor.getLogin()); if (!TextUtils.isEmpty(contributor.getAvatarUrl())) { Picasso.with(getContext()).load(contributor.getAvatarUrl()).into(viewHolder.contributorAvatar); } return convertView; }

Target:
public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = View.inflate(getContext(), R.layout.contributor_item, null); ViewHolder viewHolder = new ViewHolder(convertView); convertView.setTag(viewHolder); } Contributor contributor = getItem(position); ViewHolder viewHolder = (ViewHolder) convertView.getTag(); viewHolder.contributorName.setText(contributor.getLogin()); if (!TextUtils.isEmpty(contributor.getAvatarUrl())) { App.getInstance().getPicasso() .load(contributor.getAvatarUrl()) .into(viewHolder.contributorAvatar); } return convertView; }
Source:
public void addTerrain(Geocache cache) { if (cache.getTerrain() > 0) { if (ECConnector.getInstance().canHandle(cache.getGeocode())) { addStars(R.string.cache_terrain, cache.getTerrain(), 7); } else { addStars(R.string.cache_terrain, cache.getTerrain()); } } }

Target:
public void addTerrain(Geocache cache) { if (cache.getTerrain() > 0) { addStars(R.string.cache_terrain, cache.getTerrain(), ConnectorFactory.getConnector(cache).getMaxTerrain()); } }
Source:
public static @Nullable Integer getThreadPrio(KernelAnalysis module, Integer threadId, long ts) { Integer execPrio = null; ITmfStateSystem ss = module.getStateSystem(); if (ss == null) { return execPrio; } try { Integer execPrioQuark = ss.getQuarkAbsolute(Attributes.THREADS, threadId.toString(), Attributes.PRIO); ITmfStateInterval interval = ss.querySingleState(ts, execPrioQuark); ITmfStateValue prioValue = interval.getStateValue(); execPrio = prioValue.unboxInt(); } catch (AttributeNotFoundException | StateSystemDisposedException | TimeRangeException e) { } return execPrio; }

Target:
public static @Nullable Integer getThreadPrio(KernelAnalysis module, Integer threadId, long ts) { Integer execPrio = null; ITmfStateSystem ss = module.getStateSystem(); if (ss == null) { return execPrio; } try { int execPrioQuark = ss.getQuarkAbsolute(Attributes.THREADS, threadId.toString(), Attributes.PRIO); ITmfStateInterval interval = ss.querySingleState(ts, execPrioQuark); ITmfStateValue prioValue = interval.getStateValue(); execPrio = prioValue.unboxInt(); } catch (AttributeNotFoundException | StateSystemDisposedException | TimeRangeException e) { } return execPrio; }
Source:
private void generatePasswordIfNoneProvided(Template template) { TemplateOptions options = template.getOptions(); if (options.getLoginPassword() == null) { Optional<String> passwordOptional = template.getImage().getDefaultCredentials().getOptionalPassword(); if (passwordOptional.isPresent()) { options.overrideLoginPassword(passwordOptional.get()); return; } else { options.overrideLoginPassword(Passwords.generate()); } } }

Target:
private void generatePasswordIfNoneProvided(Template template) { TemplateOptions options = template.getOptions(); if (options.getLoginPassword() == null) { Optional<String> passwordOptional = template.getImage().getDefaultCredentials().getOptionalPassword(); options.overrideLoginPassword(passwordOptional.or(Passwords.generate())); } }
Source:
private void savePreferences() { try { List<String> groupIds = new ArrayList<>(); for (RepositoryGroup group : groupMap.values()) { String groupId = group.getGroupId().toString(); groupIds.add(groupId); String name = group.getName(); preferences.put(PREFS_GROUP_NAME_PREFIX + groupId, name); List<String> repos = group.getRepositoryDirectories(); preferences.put(PREFS_GROUP_PREFIX + groupId, StringUtils.join(repos, SEPARATOR)); } preferences.put(PREFS_GROUPS, StringUtils.join(groupIds, SEPARATOR)); preferences.flush(); } catch (BackingStoreException e) { Activator.logError( UIText.RepositoriesView_RepoGroup_ErrorSavePreferences, e); } }

Target:
private void savePreferences() { try { List<String> groupIds = new ArrayList<>(); for (RepositoryGroup group : groupMap.values()) { String groupId = group.getGroupId().toString(); groupIds.add(groupId); String name = group.getName(); preferences.put(PREFS_GROUP_NAME_PREFIX + groupId, name); String repos = group.getRepositoryDirectories().stream() .map(File::toString) .collect(Collectors.joining(SEPARATOR)); preferences.put(PREFS_GROUP_PREFIX + groupId, repos); } preferences.put(PREFS_GROUPS, StringUtils.join(groupIds, SEPARATOR)); preferences.flush(); } catch (BackingStoreException e) { Activator.logError( UIText.RepositoriesView_RepoGroup_ErrorSavePreferences, e); } }
Source:
public void checkStateChanged(CheckStateChangedEvent event) { TmfXYChartViewer chartViewer = getChartViewer(); if (chartViewer == null) { return; } if (fTreeViewer == null || fTreeViewer.getTrace() == null) { return; } ICheckable checkboxTree = event.getCheckable(); if (checkboxTree instanceof CheckboxTreeViewer) { Set<@NonNull Integer> quarks = new TreeSet<>(); for (Object checkedElement : fTriStateFilteredCheckboxTree.getCheckedElements()) { if (checkedElement instanceof CounterTreeViewerEntry) { quarks.add(((CounterTreeViewerEntry) checkedElement).getQuark()); } } if (chartViewer instanceof CounterChartViewer) { ((CounterChartViewer) chartViewer).updateChart(quarks); } } }

Target:
public void checkStateChanged(CheckStateChangedEvent event) { TmfXYChartViewer chartViewer = getChartViewer(); if (chartViewer == null) { return; } ICheckable checkboxTree = event.getCheckable(); if (checkboxTree instanceof CheckboxTreeViewer) { Set<@NonNull Integer> quarks = new TreeSet<>(); for (Object checkedElement : fTriStateFilteredCheckboxTree.getCheckedElements()) { if (checkedElement instanceof CounterTreeViewerEntry) { quarks.add(((CounterTreeViewerEntry) checkedElement).getQuark()); } } if (chartViewer instanceof CounterChartViewer) { ((CounterChartViewer) chartViewer).updateChart(quarks); } } }
Source:
public String getName() { if(getEcoreClassifier() == null) { return "null"; } return getEcoreClassifier().getName(); }

Target:
public String getName() { if(getEcoreClassifier() == null) { return ""; } return getEcoreClassifier().getName(); }
Source:
private int readNoFilter(int[] positions, int positionCount) throws IOException { int streamPosition = 0; allNulls = false; offsetVector = new int[positionCount + 1]; int offsetVectorIndex = 0; offsetVector[offsetVectorIndex] = 0; boolean isCharType = streamDescriptor.getOrcType().getOrcTypeKind() == OrcType.OrcTypeKind.CHAR; int maxCodePointCount = getMaxCodePointCount(streamDescriptor.getOrcType()); for (int i = 0; i < positionCount; i++) { int position = positions[i]; if (position > streamPosition) { skipData(streamPosition, position); streamPosition = position; } if (isNullVector != null && isNullVector[position]) { int prev = offsetVector[offsetVectorIndex]; offsetVector[++offsetVectorIndex] = prev; nulls[i] = true; } else { int currentOffSet = offsetVector[offsetVectorIndex]; int currentLength = lengthVector[lengthIndex]; int truncatedLength = 0; if (currentLength > 0) { dataStream.next(data, currentOffSet, currentOffSet + currentLength); truncatedLength = computeTruncatedLength(slice, currentOffSet, currentLength, maxCodePointCount, isCharType); Verify.verify(truncatedLength >= 0); } offsetVector[++offsetVectorIndex] = currentOffSet + truncatedLength; lengthIndex++; } streamPosition++; } outputPositionCount = positionCount; outputPositions = positions; return streamPosition; }

Target:
private int readNoFilter(int[] positions, int positionCount) throws IOException { int streamPosition = 0; allNulls = false; for (int i = 0; i < positionCount; i++) { int position = positions[i]; if (position > streamPosition) { skipData(streamPosition, position - streamPosition); streamPosition = position; } int offset = offsets[i]; if (presentStream != null && isNullVector[position]) { if (offsets != null) { offsets[i + 1] = offset; } nulls[i] = true; } else { int length = lengthVector[lengthIndex]; int truncatedLength = 0; if (length > 0) { dataStream.next(data, offset, offset + length); truncatedLength = computeTruncatedLength(dataAsSlice, offset, length, maxCodePointCount, isCharType); } offsets[i + 1] = offset + truncatedLength; lengthIndex++; if (presentStream != null) { nulls[i] = false; } } streamPosition++; } outputPositionCount = positionCount; return streamPosition; }
Source:
private Address(String address, String personal, boolean parse) { if (address == null) { throw new NullPointerException("address"); } if (parse) { Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(address); if (tokens.length > 0) { Rfc822Token token = tokens[0]; if (token.getAddress() == null) { throw new NullPointerException("token.getAddress()"); } mAddress = token.getAddress(); String name = token.getName(); if (!TextUtils.isEmpty(name)) { mPersonal = name; } else { mPersonal = (personal == null) ? null : personal.trim(); } } else { Timber.e("Invalid address: %s", address); } } else { mAddress = address; mPersonal = personal; } }

Target:
private Address(String address, String personal, boolean parse) { if (address == null) { throw new IllegalArgumentException("address"); } if (parse) { Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(address); if (tokens.length > 0) { Rfc822Token token = tokens[0]; if (token.getAddress() == null) { throw new IllegalArgumentException("token.getAddress()"); } mAddress = token.getAddress(); String name = token.getName(); if (!TextUtils.isEmpty(name)) { mPersonal = name; } else { mPersonal = (personal == null) ? null : personal.trim(); } } else { Timber.e("Invalid address: %s", address); } } else { mAddress = address; mPersonal = personal; } }
Source:
public void testBinEchoPrintsArguments() throws Exception { Spawn spawn; if (OS.getCurrent() == OS.WINDOWS) { spawn = createSpawn("C:/windows/system32/cmd.exe", "/c", "echo", "Hello,", "world."); } else { spawn = createSpawn("/bin/echo", "Hello,", "world."); } run(spawn); assertThat(out()).isEqualTo("Hello, world." + System.lineSeparator()); assertThat(err()).isEmpty(); }

Target:
public void testBinEchoPrintsArguments() throws Exception { Spawn spawn; if (OS.getCurrent() == OS.WINDOWS) { spawn = createSpawn(CMD_EXE, "/c", "echo", "Hello,", "world."); } else { spawn = createSpawn("/bin/echo", "Hello,", "world."); } run(spawn); assertThat(out()).isEqualTo("Hello, world." + System.lineSeparator()); assertThat(err()).isEmpty(); }
Source:
@Override public int selectString(Options options) throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } if (p != PEEKED_DOUBLE_QUOTED) { return -1; } int result = source.select(options.doubleQuoteSuffix); if (result == -1) { String nextString = nextString(); for (int i = 0, size = options.strings.length; i < size; i++) { if (nextString.equals(options.strings[i])) { result = i; peeked = PEEKED_NONE; pathIndices[stackSize - 1]++; break; } } if (result == -1) { peeked = PEEKED_BUFFERED; peekedString = nextString; pathIndices[stackSize - 1]--; } } else { peeked = PEEKED_NONE; pathIndices[stackSize - 1]++; } return result; }

Target:
@Override public int selectString(Options options) throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } if (p < PEEKED_SINGLE_QUOTED || p > PEEKED_BUFFERED) { return -1; } int result = source.select(options.doubleQuoteSuffix); if (result != -1) { peeked = PEEKED_NONE; pathIndices[stackSize - 1]++; return result; } String nextString = nextString(); for (int i = 0, size = options.strings.length; i < size; i++) { if (nextString.equals(options.strings[i])) { peeked = PEEKED_NONE; pathIndices[stackSize - 1]++; return i; } } peeked = PEEKED_BUFFERED; peekedString = nextString; pathIndices[stackSize - 1]--; return -1; }
Source:
public void execute(DiagnosticContext context) { try { List<RestEntry> entries = new ArrayList(); entries.addAll(context.getLogstashRestCalls().values()); runQueries(context.getEsRestClient(), entries, context.getTempDir(), 0, 0); String temp = context.getTempDir(); JsonNode nodeData = JsonYamlUtils.createJsonNodeFromFileName(temp, "logstash_node.json"); JsonNode jvm = nodeData.path("jvm"); String pid = jvm.path("pid").asText(); context.setPid(pid); } catch (Throwable t) { logger.log(SystemProperties.DIAG, "Logstash Query error:", t); throw new DiagnosticException(String.format("Error obtaining logstash output and/or process id - exiting. %s", Constants.CHECK_LOG)); } }

Target:
public void execute(DiagnosticContext context) { try { List<RestEntry> entries = new ArrayList<>(); entries.addAll(context.getLogstashRestCalls().values()); runQueries(context.getEsRestClient(), entries, context.getTempDir(), 0, 0); String temp = context.getTempDir(); JsonNode nodeData = JsonYamlUtils.createJsonNodeFromFileName(temp, "logstash_node.json"); JsonNode jvm = nodeData.path("jvm"); String pid = jvm.path("pid").asText(); context.setPid(pid); } catch (Throwable t) { logger.log(SystemProperties.DIAG, "Logstash Query error:", t); throw new DiagnosticException(String.format("Error obtaining logstash output and/or process id - exiting. %s", Constants.CHECK_LOG)); } }
Source:
private void applyConfig(Map<String, Object> config) { if (config == null) { return; } final String max = Objects.toString(config.get("maxSubscriptions"), null); if (max != null) { maxSubscriptions = Integer.parseInt(max); } }

Target:
private void applyConfig(Map<String, Object> config) { if (config == null) { return; } final String max = Objects.toString(config.get("maxSubscriptions"), null); if (max != null) { try { maxSubscriptions = Integer.parseInt(max); } catch (NumberFormatException e) { logger.debug("Setting 'maxSubscriptions' must be a number; value '{}' ignored.", max); } } }
Source:
protected View onCreateAnswerView(Context context, FormEntryPrompt prompt, int answerFontSize) { binding = WidgetAnswerBinding.inflate(((Activity) context).getLayoutInflater()); View answerView = binding.getRoot(); if (prompt.isReadOnly()) { binding.widgetButton.setVisibility(GONE); } else { binding.widgetButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, answerFontSize); binding.widgetButton.setText(getContext().getString(R.string.open_url)); binding.widgetButton.setOnClickListener(v -> onButtonClick()); } binding.widgetAnswerText.setGravity(TEXT_ALIGNMENT_CENTER); binding.widgetAnswerText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, answerFontSize); binding.widgetAnswerText.setText(prompt.getAnswerText()); return answerView; }

Target:
protected View onCreateAnswerView(Context context, FormEntryPrompt prompt, int answerFontSize) { binding = UrlWidgetAnswerBinding.inflate(((Activity) context).getLayoutInflater()); binding.urlButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, answerFontSize); binding.urlButton.setOnClickListener(v -> onButtonClick()); return binding.getRoot(); }
Source:
private List<ResourceEntry> removeAndGet(ScalarResourceEntry scalarResourceEntry, Collection<ReservationType> reservationTypesListByPriority) throws ResourceNotAvailabeException { Double requiredValue = scalarResourceEntry.getValue(); List<ResourceEntry> reservedResources = new ArrayList<>(); if (requiredValue > totalAvailableResource) { String message = String.format("ResourceType '%s' is not available. Requested value: %s Available: %s", resourceType, requiredValue, totalAvailableResource); throw new ResourceNotAvailabeException(message); } for (ReservationType reservationType : reservationTypesListByPriority) { ScalarResourceEntry availableResource = availableResourcesByReservationType.get(reservationType); Double availableResourceValue = availableResource.getValue(); if (availableResourceValue >= requiredValue) { availableResource.remove(new ScalarResourceEntry(requiredValue)); totalAvailableResource -= requiredValue; reservedResources.add(new ScalarResourceEntry(reservationType, requiredValue)); return reservedResources; } else if (availableResourceValue > 0) { availableResourcesByReservationType.put(reservationType, new ScalarResourceEntry(reservationType, 0.0)); requiredValue -= availableResourceValue; totalAvailableResource -= availableResourceValue; reservedResources.add(new ScalarResourceEntry(reservationType, availableResourceValue)); } } return reservedResources; }

Target:
private List<ResourceEntry> removeAndGet(ScalarResourceEntry scalarResourceEntry, Collection<ReservationType> reservationTypesListByPriority) throws ResourceNotAvailableException { Double requiredValue = scalarResourceEntry.getValue(); List<ResourceEntry> reservedResources = new ArrayList<>(); if (requiredValue > totalAvailableResource) { String message = String.format("ResourceType '%s' is not available. Requested value: %s Available: %s", resourceType, requiredValue, totalAvailableResource); throw new ResourceNotAvailableException(message); } for (ReservationType reservationType : reservationTypesListByPriority) { ScalarResourceEntry availableResource = availableResourcesByReservationType.get(reservationType); Double availableResourceValue = availableResource.getValue(); if (availableResourceValue >= requiredValue) { availableResource.remove(new ScalarResourceEntry(requiredValue)); totalAvailableResource -= requiredValue; reservedResources.add(new ScalarResourceEntry(reservationType, requiredValue)); return reservedResources; } else if (availableResourceValue > 0) { availableResourcesByReservationType.put(reservationType, new ScalarResourceEntry(reservationType, 0.0)); requiredValue -= availableResourceValue; totalAvailableResource -= availableResourceValue; reservedResources.add(new ScalarResourceEntry(reservationType, availableResourceValue)); } } return reservedResources; }
Source:
protected <S extends KeySpec> S engineGetKeySpec(final String algorithm, final Password password, final Class<S> keySpecType) throws InvalidKeySpecException { if (password instanceof AbstractPasswordImpl) { final AbstractPasswordImpl abstractPassword = (AbstractPasswordImpl) password; if (algorithm.equals(abstractPassword.getAlgorithm())) { return abstractPassword.getKeySpec(keySpecType); } } switch (algorithm) { case ALGORITHM_SHA256CRYPT: case ALGORITHM_SHA512CRYPT: { if (password instanceof UnixSHACryptPassword) { if (keySpecType == UnixSHACryptPasswordSpec.class) { UnixSHACryptPassword p = ((UnixSHACryptPassword) password); return keySpecType.cast(new UnixSHACryptPasswordSpec(p.getId(), p.getEncoded(), p.getSalt(), p.getIterationCount())); } } else { break; } } } throw new InvalidKeySpecException(); }

Target:
protected <S extends KeySpec> S engineGetKeySpec(final String algorithm, final Password password, final Class<S> keySpecType) throws InvalidKeySpecException { if (password instanceof AbstractPasswordImpl) { final AbstractPasswordImpl abstractPassword = (AbstractPasswordImpl) password; if (algorithm.equals(abstractPassword.getAlgorithm())) { return abstractPassword.getKeySpec(keySpecType); } } throw new InvalidKeySpecException(); }