auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public String valueForSQLExpression(EOSQLExpression context) { int count = count(); if (count == 0) { return null; } if ((context != null) && ((objectAtIndex(0) instanceof EORelationship))) { return context.sqlStringForAttributePath(this); } StringBuffer aString = _prefix != null ? new StringBuffer(_prefix) : new StringBuffer(64); int pieces; for (int i = pieces = 0; i < count; i++) { Object expression = objectAtIndex(i); String result = valueForSQLExpression(expression, context); if ((result != null) && (result.length() > 0)) { pieces++; if ((pieces > 1) && (_infix != null)) { aString.append(_infix); } aString.append(result); } } if (pieces == 0) return null; if (_suffix != null) aString.append(_suffix); return new String(aString); }

Target:
public String valueForSQLExpression(EOSQLExpression context) { int count = count(); if (count == 0) { return null; } if ((context != null) && ((objectAtIndex(0) instanceof EORelationship))) { return context.sqlStringForAttributePath(this); } StringBuilder aString = _prefix != null ? new StringBuilder(_prefix) : new StringBuilder(64); int pieces; for (int i = pieces = 0; i < count; i++) { Object expression = objectAtIndex(i); String result = valueForSQLExpression(expression, context); if ((result != null) && (result.length() > 0)) { pieces++; if ((pieces > 1) && (_infix != null)) { aString.append(_infix); } aString.append(result); } } if (pieces == 0) return null; if (_suffix != null) aString.append(_suffix); return new String(aString); }
Source:
public static void attemptObtain(ObtainableLock lock) throws IOException { int attempts = 0; while (lock.obtain()==false) { if (attempts++>MAX_LOCK_ACQUIRE_MILLISECONDS) failLockAcquire(); if (Thread.currentThread().isInterrupted()) failLockAcquire(); try { Thread.sleep(1); } catch (InterruptedException e) { Thread.currentThread().interrupt(); failLockAcquire(); } } }

Target:
public static void attemptObtain(ObtainableLock lock) throws IOException { int attempts = 0; while (!lock.obtain()) { if (attempts++ > MAX_LOCK_ACQUIRE_MILLISECONDS) failLockAcquire(); if (Thread.currentThread().isInterrupted()) failLockAcquire(); try { Thread.sleep(1); } catch (InterruptedException e) { Thread.currentThread().interrupt(); failLockAcquire(); } } }
Source:
public static HandshakeMessage fromByteArray(byte[] byteArray, InetSocketAddress peerAddress) { if(byteArray == null) { throw new NullPointerException("byte array cannot be null"); } DatagramReader reader = new DatagramReader(byteArray); int identityLength = reader.read(IDENTITY_LENGTH_BITS); byte[] identityEncoded = reader.readBytes(identityLength); int length = reader.read(LENGTH_BITS); byte[] pointEncoded = reader.readBytes(length); return new EcdhPskClientKeyExchange(identityEncoded, pointEncoded, peerAddress); }

Target:
public static HandshakeMessage fromByteArray(byte[] byteArray, InetSocketAddress peerAddress) { if (byteArray == null) { throw new NullPointerException("byte array cannot be null"); } if (peerAddress == null) { throw new NullPointerException("peer address cannot be null"); } DatagramReader reader = new DatagramReader(byteArray); int identityLength = reader.read(IDENTITY_LENGTH_BITS); byte[] identityEncoded = reader.readBytes(identityLength); int length = reader.read(LENGTH_BITS); byte[] pointEncoded = reader.readBytes(length); return new EcdhPskClientKeyExchange(identityEncoded, pointEncoded, peerAddress); }
Source:
private void validate() { boolean isRealmModeSet = _realmMode != null; boolean isZkAddressSet = _zkAddress != null && !_zkAddress.isEmpty(); if (isRealmModeSet) { if (_realmMode == RealmAwareZkClient.RealmMode.SINGLE_REALM && !isZkAddressSet) { throw new HelixException( "ConfigAccessor: RealmMode cannot be single-realm without a valid ZkAddress set!"); } } else { _realmMode = isZkAddressSet ? RealmAwareZkClient.RealmMode.SINGLE_REALM : RealmAwareZkClient.RealmMode.MULTI_REALM; } boolean isZkClientConfigSet = _realmAwareZkClientConfig != null; _realmAwareZkClientConfig = isZkClientConfigSet ? _realmAwareZkClientConfig.createHelixZkClientConfig() : new HelixZkClient.ZkClientConfig().setZkSerializer(new ZNRecordSerializer()); if (_realmAwareZkConnectionConfig == null) { _realmAwareZkConnectionConfig = new RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder().build(); } }

Target:
private void validate() { boolean isZkAddressSet = _zkAddress != null && !_zkAddress.isEmpty(); if (_realmMode == RealmAwareZkClient.RealmMode.SINGLE_REALM && !isZkAddressSet) { throw new HelixException( "ConfigAccessor: RealmMode cannot be single-realm without a valid ZkAddress set!"); } if (_realmMode == null) { _realmMode = isZkAddressSet ? RealmAwareZkClient.RealmMode.SINGLE_REALM : RealmAwareZkClient.RealmMode.MULTI_REALM; } boolean isZkClientConfigSet = _realmAwareZkClientConfig != null; _realmAwareZkClientConfig = isZkClientConfigSet ? _realmAwareZkClientConfig.createHelixZkClientConfig() : new HelixZkClient.ZkClientConfig().setZkSerializer(new ZNRecordSerializer()); if (_realmAwareZkConnectionConfig == null) { _realmAwareZkConnectionConfig = new RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder().build(); } }
Source:
public synchronized IProject get(IReferencePoint referencePoint) { if (referencePointToProjectMapper.containsKey(referencePoint)) { return referencePointToProjectMapper.get(referencePoint); } return null; }

Target:
public synchronized IProject get(IReferencePoint referencePoint) { return referencePointToProjectMapper.get(referencePoint); }
Source:
public void flush() throws IOException { if (getDepth() == 0) { int maxId = lst.getMaxId(); if (!flushed && (user.hasWrittenValuesSinceFinished() || isStreamCopyOptimized())) symbols.writeIonVersionMarker(); if (newSymbols || (!flushed && (isStreamCopyOptimized() || lstRequired))) { symbols.addTypeAnnotationSymbol(systemSymbol(ION_SYMBOL_TABLE_SID)); symbols.stepIn(STRUCT); if (flushed) { symbols.setFieldNameSymbol(systemSymbol(IMPORTS_SID)); symbols.writeSymbolToken(systemSymbol(ION_SYMBOL_TABLE_SID)); } else { SymbolTable[] tempImports = lst.getImportedTables(); if (tempImports.length > 0) { symbols.setFieldNameSymbol(systemSymbol(IMPORTS_SID)); symbols.stepIn(LIST); for (final SymbolTable st : tempImports) { symbols.stepIn(STRUCT); symbols.setFieldNameSymbol(systemSymbol(NAME_SID)); symbols.writeString(st.getName()); symbols.setFieldNameSymbol(systemSymbol(VERSION_SID)); symbols.writeInt(st.getVersion()); symbols.setFieldNameSymbol(systemSymbol(MAX_ID_SID)); symbols.writeInt(st.getMaxId()); symbols.stepOut(); } symbols.stepOut(); } } if (lstIndex < maxId) { symbols.setFieldNameSymbol(systemSymbol(SYMBOLS_SID)); symbols.stepIn(LIST); for (int i = this.lstIndex + 1; i <= maxId; i++) { symbols.writeString(this.lst.findKnownSymbol(i)); } lstIndex = maxId; symbols.stepOut(); } symbols.stepOut(); flushed = true; newSymbols = false; } symbols.flush(); user.flush(); } }

Target:
public void flush() throws IOException { if (getDepth() == 0) { int maxId = lst.getMaxId(); if (!flushed && (user.hasWrittenValuesSinceFinished() || isStreamCopyOptimized())) { symbols.writeIonVersionMarker(); } if (hasUnflushedLocalSymbols || (!flushed && (isStreamCopyOptimized() || lstRequired))) { symbols.addTypeAnnotationSymbol(systemSymbol(ION_SYMBOL_TABLE_SID)); symbols.stepIn(STRUCT); if (flushed) { symbols.setFieldNameSymbol(systemSymbol(IMPORTS_SID)); symbols.writeSymbolToken(systemSymbol(ION_SYMBOL_TABLE_SID)); } else { SymbolTable[] tempImports = lst.getImportedTables(); if (tempImports.length > 0) { symbols.setFieldNameSymbol(systemSymbol(IMPORTS_SID)); symbols.stepIn(LIST); for (final SymbolTable st : tempImports) { symbols.stepIn(STRUCT); symbols.setFieldNameSymbol(systemSymbol(NAME_SID)); symbols.writeString(st.getName()); symbols.setFieldNameSymbol(systemSymbol(VERSION_SID)); symbols.writeInt(st.getVersion()); symbols.setFieldNameSymbol(systemSymbol(MAX_ID_SID)); symbols.writeInt(st.getMaxId()); symbols.stepOut(); } symbols.stepOut(); } } if (lstIndex < maxId) { symbols.setFieldNameSymbol(systemSymbol(SYMBOLS_SID)); symbols.stepIn(LIST); for (int i = this.lstIndex + 1; i <= maxId; i++) { symbols.writeString(this.lst.findKnownSymbol(i)); } lstIndex = maxId; symbols.stepOut(); } symbols.stepOut(); flushed = true; hasUnflushedLocalSymbols = false; } symbols.flush(); user.flush(); } }
Source:
public void deleteIndex() { client.dropIndex(null, args.namespace, args.set, indexName); }

Target:
public void deleteIndex() { IndexTask task = client.dropIndex(null, args.namespace, args.set, indexName); task.waitTillComplete(); }
Source:
private Observable<Token> loginFacebook(final LoginFacebookRequest loginFacebookRequest) { Timber.v("logging in facebook...."); HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); client.interceptors().add(interceptor); Retrofit retrofit = new Retrofit.Builder() .baseUrl(this.config.getCanvassUrl()) .addConverterFactory(GsonConverterFactory.create(gson)) .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .client(client) .build(); TokenSpec.TokenEndpoint endpoint = retrofit.create(TokenSpec.TokenEndpoint.class); return endpoint.loginFacebook( getAuthString(), "password", loginFacebookRequest.username(), loginFacebookRequest.password()); }

Target:
private Observable<Token> loginFacebook(final LoginFacebookRequest loginFacebookRequest) { Timber.v("logging in facebook...."); HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); client.interceptors().add(interceptor); Retrofit retrofit = new Retrofit.Builder() .baseUrl(this.config.getCanvassUrl()) .addConverterFactory(GsonConverterFactory.create(gson)) .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .client(client) .build(); TokenSpec.TokenEndpoint endpoint = retrofit.create(TokenSpec.TokenEndpoint.class); return endpoint.loginFacebook( getAuthString(), loginFacebookRequest.getGrantType(), loginFacebookRequest.username(), loginFacebookRequest.password()); }
Source:
public void export_credentials_provider_extension_credentials() throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); ConfigurationAsCode.get().export(out); System.out.println(out.toString()); assertThat(out.toString(), containsString("username: \"user1\"")); assertThat(out.toString(), containsString("id: \"sudo_password\"")); }

Target:
public void export_credentials_provider_extension_credentials() throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); ConfigurationAsCode.get().export(out); assertThat(out.toString(), containsString("username: \"user1\"")); assertThat(out.toString(), containsString("id: \"sudo_password\"")); }
Source:
public void accumulate(Tuple input) throws IOException { for (Tuple t : (DataBag) input.get(0)) { if (this.xy != null) { int cmp = t.compareTo(this.xy); if ((cmp < 0 && this.lastCmp > 0) || (cmp > 0 && this.lastCmp < 0)) { throw new ExecException("Out of order! previous tuple: " + this.xy + ", present tuple: " + t + ", comparsion: " + cmp + ", previous comparsion: " + this.lastCmp); } if (cmp != 0) { this.combEstimator.accumulate(this.cxy); this.cxy = 0; this.lastCmp = cmp; Object prevObj = this.xy.get(0); byte prevObjType = DataType.findType(prevObj); Object presentObj = t.get(0); byte presentObjType = DataType.findType(presentObj); if(prevObjType == DataType.ERROR || presentObjType == DataType.ERROR || prevObjType != presentObjType) { throw new ExecException("Inconsistent data type of the 1st field!" + " previous object type: " + DataType.findTypeName(prevObjType) + ", present object type: " + DataType.findTypeName(presentObjType)); } if(DataType.compare(prevObj, presentObj, prevObjType, presentObjType) != 0) { this.condXEstimator.accumulate(this.cx); this.cx = 0; } } } this.xy = t; this.cx++; this.cxy++; } }

Target:
public void accumulate(Tuple input) throws IOException { for (Tuple t : (DataBag) input.get(0)) { if (this.xy != null) { int cmp = t.compareTo(this.xy); if ((cmp < 0 && this.lastCmp > 0) || (cmp > 0 && this.lastCmp < 0)) { throw new ExecException("Out of order! previous tuple: " + this.xy + ", present tuple: " + t + ", comparsion: " + cmp + ", previous comparsion: " + this.lastCmp); } if (cmp != 0) { this.combEstimator.accumulate(this.cxy); this.cxy = 0; this.lastCmp = cmp; if(DataType.compare(this.xy.get(0), t.get(0)) != 0) { this.condXEstimator.accumulate(this.cx); this.cx = 0; } } } this.xy = t; this.cx++; this.cxy++; } }
Source:
private ServerSocket openServerSocket() { ServerSocket serverSocket = null; for (int i = 40000; i < 40100; i++) { try { serverSocket = new ServerSocket(i); } catch (IOException e) { } } assertNotNull(serverSocket, "No ports available in range!"); return serverSocket; }

Target:
private ServerSocket openServerSocket() { int lowerBound = 40000; int upperBound = 40100; for (int i = lowerBound; i < upperBound; i++) { try { return new ServerSocket(i); } catch (IOException e) { } } throw new IllegalStateException("No ports available in range "+lowerBound+" to "+upperBound); }
Source:
public String format(String value) { String decodedLink = value; String toDecode = value; Matcher matcher = PATTERN_URL.matcher(value); if (matcher.find()) { toDecode = matcher.group(1); } try { decodedLink = URLDecoder.decode(toDecode, StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException e) { LOGGER.warn("Used unsupported character encoding", e); } String result = new RemoveLatexCommandsFormatter().format(decodedLink); return result; }

Target:
public String format(String value) { String decodedLink = value; String toDecode = value; Matcher matcher = PATTERN_URL.matcher(value); if (matcher.find()) { toDecode = matcher.group(1); } try { decodedLink = URLDecoder.decode(toDecode, StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException e) { LOGGER.warn("Used unsupported character encoding", e); } return decodedLink; }
Source:
public Fake(final Request req, final String... params) { super(req); if (params.length % 2 != 0) { throw new IllegalArgumentException( "Wrong number of parameters" ); } this.map = new ConcurrentHashMap<String, List<String>>(0); for (int idx = 0; idx < params.length; idx += 2) { final String key = params[idx]; final String value = params[idx + 1]; if (this.map.containsKey(key)) { this.map.get(key).add(value); } else { final List<String> values = new ArrayList<String>(1); values.add(value); this.map.put(key, values); } } }

Target:
public Fake(final Request req, final String... params) throws IOException { if (params.length % 2 != 0) { throw new IllegalArgumentException( "Wrong number of parameters" ); } final StringBuilder builder = new StringBuilder(); for (int idx = 0; idx < params.length; idx += 2) { final String key = RqForm.Fake.encode(params[idx]); final String value = RqForm.Fake.encode(params[idx + 1]); builder.append(key) .append(RqForm.KV_SEPARATOR) .append(value) .append(RqForm.PARAM_SEPARATOR); } this.fake = new RqForm.Base( new RqWithBody(req, builder.toString()) ); }
Source:
public static void setupFolder() { workingDirString = currentDirString + "/../temp/TestHadoopSpark"; workingDirFile = new File(workingDirString); libFolderFile = new File(workingDirFile, "lib"); libFolderFile = new File(workingDirFile, "lib"); executionJarFile = new File(libFolderFile, "hadoop-spark-job-test-execution-x.y.z-a.b.c" + ".jar"); libraryJarFile = new File(libFolderFile, "library.jar"); }

Target:
public static void setupFolder() { workingDirString = currentDirString + "/../temp/TestHadoopSpark"; workingDirFile = new File(workingDirString); libFolderFile = new File(workingDirFile, "lib"); executionJarFile = new File(libFolderFile, "hadoop-spark-job-test-execution-x.y.z-a.b.c" + ".jar"); libraryJarFile = new File(libFolderFile, "library.jar"); }
Source:
public static void init() { bai = new DiskBasedBAMFileIndex(new File("src/test/resources/htsjdk/samtools/BAMFileIndexTest/index_test.bam.bai"), null); csi = new CSIIndex(new File("src/test/resources/htsjdk/samtools/BAMFileIndexTest/index_test.bam.csi"), false, null); mcsi = new CSIIndex(new File("src/test/resources/htsjdk/samtools/BAMFileIndexTest/index_test.bam.csi"), true, null); try { ucsi = new CSIIndex(Paths.get("src/test/resources/htsjdk/samtools/BAMFileIndexTest/uncompressed_index.bam.csi"), null); } catch (IOException e) { e.printStackTrace(); } ubai = new DiskBasedBAMFileIndex(new File("src/test/resources/htsjdk/samtools/BAMFileIndexTest/uncompressed_index.bam.bai"),null); }

Target:
public void init() { bai = new DiskBasedBAMFileIndex(new File(TEST_DATA_DIR, "index_test.bam.bai"), null); csi = new CSIIndex(new File(TEST_DATA_DIR, "index_test.bam.csi"), false, null); mcsi = new CSIIndex(new File(TEST_DATA_DIR, "index_test.bam.csi"), true, null); try { ucsi = new CSIIndex(Paths.get(TEST_DATA_DIR, "uncompressed_index.bam.csi"), null); } catch (IOException e) { e.printStackTrace(); } ubai = new DiskBasedBAMFileIndex(new File(TEST_DATA_DIR, "uncompressed_index.bam.bai"), null); }
Source:
public static org.schabi.newpipe.extractor.localization.Localization getPreferredLocalization(final Context context) { final String contentLanguage = PreferenceManager .getDefaultSharedPreferences(context) .getString(context.getString(R.string.content_language_key), context.getString(R.string.default_language_value)); if (contentLanguage.equals("system")) { return org.schabi.newpipe.extractor.localization.Localization.fromLocale(Locale.getDefault()); } return org.schabi.newpipe.extractor.localization.Localization.fromLocalizationCode(contentLanguage); }

Target:
public static org.schabi.newpipe.extractor.localization.Localization getPreferredLocalization(final Context context) { final String contentLanguage = PreferenceManager .getDefaultSharedPreferences(context) .getString(context.getString(R.string.content_language_key), context.getString(R.string.default_localization_key)); if (contentLanguage.equals(context.getString(R.string.default_localization_key))) { return org.schabi.newpipe.extractor.localization.Localization.fromLocale(Locale.getDefault()); } return org.schabi.newpipe.extractor.localization.Localization.fromLocalizationCode(contentLanguage); }
Source:
public boolean isStoreByValue() { CopierConfiguration copierConfig = findSingletonAmongst(CopierConfiguration.class, cacheConfiguration.getServiceConfigurations()); return copierConfig == null; }

Target:
public boolean isStoreByValue() { CopierConfiguration copierConfig = findSingletonAmongst(CopierConfiguration.class, cacheConfiguration.getServiceConfigurations()); return copierConfig != null; }
Source:
public static List<WindowsSoundCard> getSoundCards() { List<WindowsSoundCard> cards = new ArrayList<>(); if (AUDIO_CARD_QUERY_RESULT.getResultCount() == 0) { LOG.warn("No Sound Cards Found..."); } else { for (int i = 0; i < AUDIO_CARD_QUERY_RESULT.getResultCount(); i++) { cards.add(new WindowsSoundCard(getAudioCardKernelVersion(i), getAudioCardCompleteName(i), getAudioCardName(i))); } } return cards; }

Target:
public static List<WindowsSoundCard> getSoundCards() { WbemcliUtil.WmiQuery<SoundCardKernel> cardKernelQuery = new WbemcliUtil.WmiQuery<>(driverQueryClause, SoundCardKernel.class); WbemcliUtil.WmiResult<SoundCardKernel> cardKernelQueryResult = WmiUtil.queryWMI(cardKernelQuery); List<WindowsSoundCard> soundCards = new ArrayList<>(); for (int i = 0; i < cardKernelQueryResult.getResultCount(); i++) { if (NAME_MAP.containsKey(WmiUtil.getString(cardKernelQueryResult, SoundCardKernel.DEVICENAME, i))) { soundCards.add(new WindowsSoundCard(getAudioCardKernelVersion(i, cardKernelQueryResult), WmiUtil.getString(cardKernelQueryResult, SoundCardKernel.DRIVERPROVIDERNAME, i) + " " + WmiUtil.getString(cardKernelQueryResult, SoundCardKernel.DEVICENAME, i), (WmiUtil.getString(cardKernelQueryResult, SoundCardKernel.DEVICENAME, i)))); } } return soundCards; }
Source:
public void findUserByNameShouldReturnUserDtoWhenUserWasFound() { given(userRepository.findByUserName(USER_NAME)).willReturn(userEntity); UserDTO result = userService.findUserByName(USER_NAME); assertThat(result, is(detailedUserDTO)); }

Target:
public void findUserByNameShouldReturnUserDtoWhenUserWasFound() { given(userRepository.findByUserName(USER_NAME)).willReturn(userEntity); UserDTO result = userService.findUserByName(USER_NAME); then(modelMapper).should().map(userEntity, UserDTO.class); then(userRepository).should().findByUserName(USER_NAME); assertThat(result, is(detailedUserDTO)); }
Source:
public void canGetMetadataForAll() { Map<TableReference, byte[]> metadataMap = getTestKvs().getMetadataForTables(); assertThat(getTestKvs().getMetadataForTables().get(TEST_TABLE)) .isEqualTo(AtlasDbConstants.GENERIC_TABLE_METADATA); assertThat(metadataMap.get(TEST_TABLE)).isEqualTo(AtlasDbConstants.GENERIC_TABLE_METADATA); }

Target:
public void canGetMetadataForAll() { assertThat(getTestKvs().getMetadataForTables().get(TEST_TABLE)) .isEqualTo(AtlasDbConstants.GENERIC_TABLE_METADATA); }
Source:
@Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { actionMode = mode; mode.setTag(getTag()); mode.getMenuInflater().inflate(R.menu.menu_action_mode_reading_list, menu); return true; }

Target:
@Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { super.onCreateActionMode(mode, menu); mode.getMenuInflater().inflate(R.menu.menu_action_mode_reading_list, menu); actionMode = mode; return true; }
Source:
public void testBaseDeliveryIgnoresEndpoint() { Delivery delivery = new Delivery() { @Override public void deliver(Serializer serializer, Object object, Map<String, String> headers) { } @Override public void close() { } }; config.delivery = delivery; config.sessionDelivery = delivery; config.setEndpoints("<LINK_0>", "<LINK_1>"); }

Target:
public void testBaseDeliveryIgnoresEndpoint() { Delivery delivery = new Delivery() { @Override public void deliver(Serializer serializer, Object object, Map<String, String> headers) { } @Override public void close() { } }; config.delivery = delivery; config.sessionDelivery = delivery; ByteArrayOutputStream baos = new ByteArrayOutputStream(); System.setErr(new PrintStream(baos)); config.setEndpoints("<LINK_0>", "<LINK_1>"); String logMsg = new String(baos.toByteArray()); assertTrue(logMsg.contains("Delivery is not instance of " + "HttpDelivery, cannot set notify endpoint")); assertTrue(logMsg.contains("Delivery is not instance of " + "HttpDelivery, cannot set sessions endpoint")); }
Source:
protected VdcActionParametersBase getParametersForTask(VdcActionType actionType, VdcActionParametersBase parameters) { VdcActionType parentCommandType = getParentCommand(actionType); VdcActionParametersBase parentParameters = null; if (parentHasCallback()) { if (getTaskType() == AsyncTaskType.notSupported) { parentParameters = getParameters().getParentParameters(); } } else { parentParameters = getParameters().getParentParameters(); } if (parentCommandType == VdcActionType.Unknown || parentParameters == null) { return parameters; } parentParameters.setExecutionReason(parameters.getExecutionReason()); parentParameters.setCommandType(parentCommandType); return parentParameters; }

Target:
protected VdcActionParametersBase getParametersForTask(VdcActionType actionType, VdcActionParametersBase parameters) { VdcActionType parentCommandType = getParentCommandType(actionType); VdcActionParametersBase parentParameters = getParentParameters(); if (parentCommandType == VdcActionType.Unknown || parentParameters == null) { return parameters; } parentParameters.setExecutionReason(parameters.getExecutionReason()); parentParameters.setCommandType(parentCommandType); return parentParameters; }
Source:
private boolean hasNonEmptyNameDefinition(EStructuralFeature labelStyleFeature) { boolean hasEmptyNameDefinition = true; if (edge.getActualMapping() instanceof EdgeMapping) { EdgeMapping actualMapping = (EdgeMapping) edge.getActualMapping(); EdgeStyleDescription style = actualMapping.getStyle(); if (style != null && style.eGet(labelStyleFeature) != null) { String labelExpression = ((BasicLabelStyleDescription) style.eGet(labelStyleFeature)).getLabelExpression(); hasEmptyNameDefinition = labelExpression.trim().length() != 0; hasEmptyNameDefinition = hasEmptyNameDefinition && isLabelExpressionEmpty(labelExpression); } } return hasEmptyNameDefinition; }

Target:
private boolean hasNonEmptyNameDefinition(EStructuralFeature labelStyleFeature) { boolean hasEmptyNameDefinition = true; if (edge.getActualMapping() instanceof EdgeMapping) { EdgeMapping actualMapping = (EdgeMapping) edge.getActualMapping(); EdgeStyleDescription style = actualMapping.getStyle(); if (style != null) { Object labelStyle = style.eGet(labelStyleFeature); if (labelStyle instanceof BasicLabelStyleDescription) { String labelExpression = ((BasicLabelStyleDescription) labelStyle).getLabelExpression(); hasEmptyNameDefinition = labelExpression.trim().length() != 0; hasEmptyNameDefinition = hasEmptyNameDefinition && isLabelExpressionEmpty(labelExpression); } } } return hasEmptyNameDefinition; }
Source:
public boolean removeIfNotReferenced(KerberosKeytabEntity kerberosKeytabEntity) { if (kerberosKeytabEntity != null) { if (!CollectionUtils.isEmpty(kerberosKeytabEntity.getKerberosKeytabPrincipalEntities())) { ArrayList<String> ids = new ArrayList<>(); for (KerberosKeytabPrincipalEntity entity : kerberosKeytabEntity.getKerberosKeytabPrincipalEntities()) { Long id = entity.getKkpId(); if (id != null) { ids.add(String.valueOf(id)); } } LOG.debug(String.format("keytab entry for %s is still referenced by [%s]", kerberosKeytabEntity.getKeytabPath(), String.join(",", ids))); } else { LOG.debug(String.format("keytab entry for %s is no longer referenced. It will be removed.", kerberosKeytabEntity.getKeytabPath())); remove(kerberosKeytabEntity); return true; } } return false; }

Target:
public boolean removeIfNotReferenced(KerberosKeytabEntity kerberosKeytabEntity) { if (kerberosKeytabEntity != null) { if (CollectionUtils.isNotEmpty(kerberosKeytabEntity.getKerberosKeytabPrincipalEntities())) { ArrayList<String> ids = new ArrayList<>(); for (KerberosKeytabPrincipalEntity entity : kerberosKeytabEntity.getKerberosKeytabPrincipalEntities()) { Long id = entity.getKkpId(); if (id != null) { ids.add(String.valueOf(id)); } } LOG.debug(String.format("keytab entry for %s is still referenced by [%s]", kerberosKeytabEntity.getKeytabPath(), String.join(",", ids))); } else { LOG.debug(String.format("keytab entry for %s is no longer referenced. It will be removed.", kerberosKeytabEntity.getKeytabPath())); remove(kerberosKeytabEntity); return true; } } return false; }
Source:
public JsonNode getBodyJson() { ObjectNode node = JsonNodeFactory.instance.objectNode(); if (queryExpression != null) { node.set("query", queryExpression.toJson()); } appendExecutionToJson(node); return node; }

Target:
public JsonNode getBodyJson() { ObjectNode node = (ObjectNode)super.getBodyJson(); if (queryExpression != null) { node.set("query", queryExpression.toJson()); } return node; }
Source:
public ParametersDefinitionProperty(@Nonnull ParameterDefinition... parameterDefinitions) { if (parameterDefinitions != null) { this.parameterDefinitions = Arrays.asList(parameterDefinitions); } else { this.parameterDefinitions = Collections.emptyList(); } }

Target:
public ParametersDefinitionProperty(@Nonnull ParameterDefinition... parameterDefinitions) { if (parameterDefinitions == null) { throw new NullPointerException("ParameterDefinitions is null when this is a not valid value"); } this.parameterDefinitions = Arrays.asList(parameterDefinitions) ; }
Source:
public String getGroup(Object instance) { PrivilegedAction<Object> action = () -> invokeAccessibly(instance, method, Util.EMPTY_OBJECT_ARRAY); Object object = System.getSecurityManager() == null ? action.run() : AccessController.doPrivileged(action); return String.class.cast(object); }

Target:
public String getGroup(Object instance) { Object object; if (System.getSecurityManager() == null) { object = invokeAccessibly(instance, method, Util.EMPTY_OBJECT_ARRAY); } else { object = AccessController.doPrivileged((PrivilegedAction<Object>) () -> invokeAccessibly(instance, method, Util.EMPTY_OBJECT_ARRAY)); } return String.class.cast(object); }
Source:
public XML getXml(ObjectNode node, String location, ParseResult result){ if (node == null) { return null; } XML xml = new XML(); String value = getString("name", node, false, location + ".name", result); xml.setName(value); value = getString("namespace", node, false, location + ".url", result); xml.setNamespace(value); value = getString("prefix", node, false, location + ".email", result); xml.setPrefix(value); Boolean attribute = getBoolean("attribute", node, false, location, result); xml.setAttribute(attribute); Boolean wrapped = getBoolean("wrapped", node, false, location, result); xml.setWrapped(wrapped); return xml; }

Target:
public XML getXml(ObjectNode node, String location, ParseResult result){ if (node == null) { return null; } XML xml = new XML(); String value = getString("name", node, false, location + ".name", result); if(StringUtils.isNotBlank(value)){ xml.setName(value); } value = getString("namespace", node, false, location + ".url", result); if(StringUtils.isNotBlank(value)){ xml.setNamespace(value); } value = getString("prefix", node, false, location + ".email", result); if(StringUtils.isNotBlank(value)){ xml.setPrefix(value); } Boolean attribute = getBoolean("attribute", node, false, location, result); if(attribute != null){ xml.setAttribute(attribute); } Boolean wrapped = getBoolean("wrapped", node, false, location, result); if(wrapped != null){ xml.setWrapped(wrapped); } Map <String,Object> extensions = getExtensions(node,location,result); if(extensions != null && extensions.size() > 0) { xml.setExtensions(extensions); } return xml; }
Source:
public void modifiedService(ServiceReference reference, Object service) { logger.debug("ModuleHandlerFactory modified, updating handlers"); ModuleHandlerFactory moduleHandlerFactory = ((ModuleHandlerFactory) service); @SuppressWarnings("unchecked") Collection<String> removed_handlers = (Collection<String>) reference.getProperty("removed_handlers"); @SuppressWarnings("unchecked") Collection<String> added_handlers = (Collection<String>) reference.getProperty("added_handlers"); if (removed_handlers != null && removed_handlers.size() > 0) { removeMissingModuleTypes(removed_handlers); } if (added_handlers != null && added_handlers.size() > 0) { addNewModuleTypes(moduleHandlerFactory, added_handlers); } }

Target:
public void modifiedService(ServiceReference reference, Object service) { logger.debug("ModuleHandlerFactory modified, updating handlers"); ModuleHandlerFactory moduleHandlerFactory = ((ModuleHandlerFactory) service); Collection<String> types = new HashSet<String>(moduleHandlerFactory.getTypes()); HashSet<String> newTypes = new HashSet<String>(moduleHandlerFactory.getTypes()); ArrayList<String> removedTypes = new ArrayList<String>(); for (Map.Entry<String, ModuleHandlerFactory> entry : moduleHandlerFactories.entrySet()) { if (entry.getValue().equals(moduleHandlerFactory)) { String key = entry.getKey(); if (types.contains(key)) { newTypes.remove(key); } else { removedTypes.add(key); } } } if (removedTypes.size() > 0) { removeMissingModuleTypes(removedTypes); } if (newTypes.size() > 0) { addNewModuleTypes(moduleHandlerFactory, newTypes); } }
Source:
public void testStaleRemoteLocks() throws Exception { tm(1).begin(); try { cache(1).put(1, "val_1"); cache(1).put(2, "val_2"); tm(1).commit(); } catch (Throwable e) { if (tm(1).getTransaction() != null) { tm(1).rollback(); } } assertValue(1, 1, "val_1"); assertValue(1, 2, "val_2"); assertFalse(checkLocked(1, 1)); assertFalse(checkLocked(1, 2)); eventually(new Condition() { @Override public boolean isSatisfied() throws Exception { return !checkLocked(0, 1) && !checkLocked(0, 2); } }); cache(0).put(1, "new_val_1"); assertValue(0, 1, "new_val_1"); assertValue(1, 1, null); assertValue(1, 2, "val_2"); }

Target:
public void testStaleRemoteLocks() throws Exception { TestingUtil.withTx(tm(1), new Callable<Object>() { @Override public Object call() throws Exception { cache(1).put(1, "val_1"); cache(1).put(2, "val_2"); return null; } }); assertValue(1, 1, "val_1"); assertValue(1, 2, "val_2"); assertFalse(checkLocked(1, 1)); assertFalse(checkLocked(1, 2)); eventually(new Condition() { @Override public boolean isSatisfied() throws Exception { return !checkLocked(0, 1) && !checkLocked(0, 2); } }); cache(0).put(1, "new_val_1"); assertValue(0, 1, "new_val_1"); assertValue(1, 1, null); assertValue(1, 2, "val_2"); }
Source:
public XmlMementoSerializer(ClassLoader classLoader) { this.classLoader = checkNotNull(classLoader, "classLoader"); xstream.alias("brooklyn", MutableBrooklynMemento.class); xstream.alias("entity", BasicEntityMemento.class); xstream.alias("location", BasicLocationMemento.class); xstream.alias("configKey", BasicConfigKey.class); xstream.alias("attributeSensor", BasicAttributeSensor.class); xstream.registerConverter(new ConverterImpl(Location.class, new Function<Location,String>() { @Override public String apply(Location input) { return (input != null) ? input.getId() : null; }})); xstream.registerConverter(new ConverterImpl(Entity.class, new Function<Entity,String>() { @Override public String apply(Entity input) { return (input != null) ? input.getId() : null; }})); xstream.registerConverter(new ConverterImpl(EntityAdjunct.class, new Function<EntityAdjunct,String>() { @Override public String apply(EntityAdjunct input) { return (input != null) ? input.getId() : null; }})); }

Target:
public XmlMementoSerializer(ClassLoader classLoader) { this.classLoader = checkNotNull(classLoader, "classLoader"); xstream.alias("brooklyn", MutableBrooklynMemento.class); xstream.alias("entity", BasicEntityMemento.class); xstream.alias("location", BasicLocationMemento.class); xstream.alias("configKey", BasicConfigKey.class); xstream.alias("attributeSensor", BasicAttributeSensor.class); xstream.registerConverter(new ConverterImpl(Location.class)); xstream.registerConverter(new ConverterImpl(Entity.class)); xstream.registerConverter(new ConverterImpl(EntityAdjunct.class)); }
Source:
public String createEntity(Referenceable referenceable) throws AtlasException { String entityJSON = InstanceSerialization.toJson(referenceable, true); log.debug("Creating new entity [{}]", entityJSON); List<String> guids = _createEntities(entityJSON); log.debug("Created instance for type [{}]", referenceable.getTypeName() + ", guids: " + guids); if(guids == null || guids.isEmpty()) { return null; } return guids.get(0); }

Target:
public String createEntity(Referenceable referenceable) throws AtlasException { String entityJSON = InstanceSerialization.toJson(referenceable, true); LOG.debug("Creating new entity [{}]", entityJSON); List<String> guids = _createEntities(entityJSON); LOG.debug("Created instance for type [{}]", referenceable.getTypeName() + ", guids: " + guids); return guids != null && !guids.isEmpty() ? guids.get(0) : null; }
Source:
void dropTables(final Set<TableReference> tablesToDrop) { try { clientPool.runWithRetry(client -> { KsDef ks = client.describe_keyspace(config.getKeyspaceOrThrow()); Set<TableReference> existingTables = Sets.newHashSet(); existingTables.addAll(ks.getCf_defs().stream() .map(CassandraKeyValueServices::tableReferenceFromCfDef) .collect(Collectors.toList())); for (TableReference table : tablesToDrop) { CassandraVerifier.sanityCheckTableName(table); if (existingTables.contains(table)) { CassandraKeyValueServices.runWithWaitingForSchemas( () -> truncateThenDrop(table, client), config, client, "dropping the column family for table " + table + " in a call to drop tables"); cassandraTableMetadata.deleteAllRowsForTable(table); } else { log.warn("Ignored call to drop a table ({}) that did not exist.", LoggingArgs.tableRef(table)); } } return null; }); } catch (Exception e) { throw Throwables.unwrapAndThrowAtlasDbDependencyException(e); } }

Target:
void dropTables(final Set<TableReference> tablesToDrop) { try { clientPool.runWithRetry(client -> { KsDef ks = client.describe_keyspace(config.getKeyspaceOrThrow()); Set<TableReference> existingTables = Sets.newHashSet(); existingTables.addAll(ks.getCf_defs().stream() .map(CassandraKeyValueServices::tableReferenceFromCfDef) .collect(Collectors.toList())); for (TableReference table : tablesToDrop) { CassandraVerifier.sanityCheckTableName(table); if (existingTables.contains(table)) { CassandraKeyValueServices.runWithWaitingForSchemas( () -> truncateThenDrop(table, client), config, client, "dropping the column family for table " + table + " in a call to drop tables"); cassandraTableMetadata.deleteAllMetadataRowsForTable(table); } else { log.warn("Ignored call to drop a table ({}) that did not exist.", LoggingArgs.tableRef(table)); } } return null; }); } catch (Exception e) { throw Throwables.unwrapAndThrowAtlasDbDependencyException(e); } }
Source:
private void launchTcpSlaveAgentListener() throws IOException { synchronized(tcpSlaveAgentListenerLock) { if (tcpSlaveAgentListener != null && tcpSlaveAgentListener.configuredPort != slaveAgentPort) { tcpSlaveAgentListener.shutdown(); tcpSlaveAgentListener = null; } if (slaveAgentPort != -1 && tcpSlaveAgentListener == null) { final String administrativeMonitorId = getClass().getName() + ".tcpBind"; try { tcpSlaveAgentListener = new TcpSlaveAgentListener(slaveAgentPort); AdministrativeMonitor toBeRemoved = null; ExtensionList<AdministrativeMonitor> all = AdministrativeMonitor.all(); for (Iterator<AdministrativeMonitor> it = all.iterator(); it.hasNext(); ) { AdministrativeMonitor am = it.next(); if (administrativeMonitorId.equals(am.id)) { toBeRemoved = am; break; } } all.remove(toBeRemoved); } catch (BindException e) { LOGGER.log(Level.WARNING, String.format("Failed to listen to incoming agent connections through JNLP port %s. Change the JNLP port number", slaveAgentPort), e); new AdministrativeError(administrativeMonitorId, "Failed to listen to incoming agent connections through JNLP", "Failed to listen to incoming agent connections through JNLP. <a href='configureSecurity'>Change the JNLP port number</a> to solve the problem.", e); } } } }

Target:
private void launchTcpSlaveAgentListener() throws IOException { synchronized(tcpSlaveAgentListenerLock) { if (tcpSlaveAgentListener != null && tcpSlaveAgentListener.configuredPort != slaveAgentPort) { tcpSlaveAgentListener.shutdown(); tcpSlaveAgentListener = null; } if (slaveAgentPort != -1 && tcpSlaveAgentListener == null) { final String administrativeMonitorId = getClass().getName() + ".tcpBind"; try { tcpSlaveAgentListener = new TcpSlaveAgentListener(slaveAgentPort); AdministrativeMonitor toBeRemoved = null; ExtensionList<AdministrativeMonitor> all = AdministrativeMonitor.all(); for (AdministrativeMonitor am : all) { if (administrativeMonitorId.equals(am.id)) { toBeRemoved = am; break; } } all.remove(toBeRemoved); } catch (BindException e) { LOGGER.log(Level.WARNING, String.format("Failed to listen to incoming agent connections through JNLP port %s. Change the JNLP port number", slaveAgentPort), e); new AdministrativeError(administrativeMonitorId, "Failed to listen to incoming agent connections through JNLP", "Failed to listen to incoming agent connections through JNLP. <a href='configureSecurity'>Change the JNLP port number</a> to solve the problem.", e); } } } }
Source:
public static void main(String[] args) throws BookDuplicateException, BookNotFoundException, VersionMismatchException { long bookId = 1; BookRepository bookRepository = new BookRepository(); Book book = new Book(); book.setId(bookId); bookRepository.add(book); LOGGER.info("An empty book with version was added to repository", book.getVersion()); final Book aliceBook = bookRepository.get(bookId); final Book bobBook = bookRepository.get(bookId); aliceBook.setTitle("Kama Sutra"); bookRepository.update(aliceBook); LOGGER.info("Alice updates the book with new version {}", aliceBook.getVersion()); bobBook.setAuthor("Vatsyayana Mallanaga"); try { LOGGER.info("Bob tries to update the book with his version {}", bobBook.getVersion()); bookRepository.update(bobBook); } catch (VersionMismatchException e) { LOGGER.info("Exception: {}", e.getMessage()); } }

Target:
public static void main(String[] args) throws BookDuplicateException, BookNotFoundException, VersionMismatchException { var bookId = 1; var bookRepository = new BookRepository(); var book = new Book(); book.setId(bookId); bookRepository.add(book); LOGGER.info("An empty book with version was added to repository", book.getVersion()); final var aliceBook = bookRepository.get(bookId); final var bobBook = bookRepository.get(bookId); aliceBook.setTitle("Kama Sutra"); bookRepository.update(aliceBook); LOGGER.info("Alice updates the book with new version {}", aliceBook.getVersion()); bobBook.setAuthor("Vatsyayana Mallanaga"); try { LOGGER.info("Bob tries to update the book with his version {}", bobBook.getVersion()); bookRepository.update(bobBook); } catch (VersionMismatchException e) { LOGGER.info("Exception: {}", e.getMessage()); } }
Source:
@Override public void setId(EngineBackupLogId id) { dbName = id.getDbName(); doneAt = id.getDoneAt(); }

Target:
public void setId(EngineBackupLogId id) { dbName = id.getDbName(); doneAt = id.getDoneAt(); }
Source:
public List<storage_domains> listFailedAutorecoverables() { return new SimpleJdbcTemplate(jdbcTemplate).query("select * from storage_domains where recoverable and status = " + StorageDomainStatus.InActive.getValue(), StorageDomainRowMapper.instance); }

Target:
public List<storage_domains> listFailedAutorecoverables() { return getCallsHandler().executeReadList("GetFailingVdss", StorageDomainRowMapper.instance, null); }
Source:
public static Map getTenantBasedPublisherDomainMapping(String tenantDomain) throws APIManagementException { try { Registry registry = ServiceReferenceHolder.getInstance().getRegistryService(). getGovernanceSystemRegistry(); String resourcePath = APIConstants.API_DOMAIN_MAPPINGS.replace(APIConstants.API_DOMAIN_MAPPING_TENANT_ID_IDENTIFIER, tenantDomain); if (registry.resourceExists(resourcePath)) { Resource resource = registry.get(resourcePath); String content = new String((byte[]) resource.getContent(), Charset.defaultCharset()); JSONParser parser = new JSONParser(); JSONObject mappings = (JSONObject) parser.parse(content); if (mappings.containsKey(APIConstants.API_DOMAIN_MAPPINGS_PUBLISHER)) { return (Map) mappings.get(APIConstants.API_DOMAIN_MAPPINGS_PUBLISHER); } } } catch (RegistryException e) { String msg = "Error while retrieving publisher domain mappings from registry"; throw new APIManagementException(msg, e); } catch (ClassCastException e) { String msg = "Invalid JSON found in the publisher tenant domain mappings"; throw new APIManagementException(msg, e); } catch (ParseException e) { String msg = "Malformed JSON found in the publisher tenant domain mappings"; throw new APIManagementException(msg, e); } return null; }

Target:
public static Map getTenantBasedPublisherDomainMapping(String tenantDomain) throws APIManagementException { try { Registry registry = ServiceReferenceHolder.getInstance().getRegistryService(). getGovernanceSystemRegistry(); String resourcePath = APIConstants.API_DOMAIN_MAPPINGS.replace(APIConstants.API_DOMAIN_MAPPING_TENANT_ID_IDENTIFIER, tenantDomain); if (registry.resourceExists(resourcePath)) { Resource resource = registry.get(resourcePath); String content = new String((byte[]) resource.getContent(), Charset.defaultCharset()); JSONParser parser = new JSONParser(); JSONObject mappings = (JSONObject) parser.parse(content); if (mappings.containsKey(APIConstants.API_DOMAIN_MAPPINGS_PUBLISHER)) { return (Map) mappings.get(APIConstants.API_DOMAIN_MAPPINGS_PUBLISHER); } } } catch (RegistryException e) { String msg = "Error while retrieving publisher domain mappings from registry"; throw new APIManagementException(msg, e); } catch (ParseException e) { String msg = "Malformed JSON found in the publisher tenant domain mappings"; throw new APIManagementException(msg, e); } return null; }
Source:
protected EEFWidgetStyle getWidgetStyle(EEFConditionalStyle conditionalStyle) { return ((EEFButtonConditionalStyle) conditionalStyle).getStyle(); }

Target:
protected EEFWidgetStyle getWidgetStyle(EEFConditionalStyle conditionalStyle) { if (conditionalStyle instanceof EEFButtonConditionalStyle) { return ((EEFButtonConditionalStyle) conditionalStyle).getStyle(); } return null; }
Source:
public KeySelectorResult select(KeyInfo keyInfo, KeySelector.Purpose purpose, AlgorithmMethod method, XMLCryptoContext context) throws KeySelectorException { Iterator ki = keyInfo.getContent().iterator(); while (ki.hasNext()) { XMLStructure info = (XMLStructure) ki.next(); if (!(info instanceof DOMKeyValue)) continue; final PublicKey pk; try { pk = ((DOMKeyValue) info).getPublicKey(); } catch (KeyException e) { throw new KeySelectorException(e); } if (algEquals(method.getAlgorithm(), pk.getAlgorithm())) { return new KeySelectorResult() { public Key getKey() { return pk; } }; } } throw new KeySelectorException("No key found!"); }

Target:
public KeySelectorResult select(KeyInfo keyInfo, KeySelector.Purpose purpose, AlgorithmMethod method, XMLCryptoContext context) throws KeySelectorException { for (Object o : keyInfo.getContent()) { XMLStructure info = (XMLStructure) o; if (!(info instanceof DOMKeyValue)) continue; final PublicKey pk; try { pk = ((DOMKeyValue) info).getPublicKey(); } catch (KeyException e) { throw new KeySelectorException(e); } if (algEquals(method.getAlgorithm(), pk.getAlgorithm())) { return new KeySelectorResult() { public Key getKey() { return pk; } }; } } throw new KeySelectorException("No key found!"); }
Source:
public void sendUpdate(List<GameObjectDAO> posList) { try { Thread.sleep(20); } catch (InterruptedException e) { e.printStackTrace(); } ByteBuffer buffer = ByteBuffer.allocate(1024); buffer.order(ByteOrder.LITTLE_ENDIAN); buffer.put((byte)1); buffer.put((byte)Opcodes.POSITION_UPDATE.getValue()); buffer.put((byte)2); for (int i = 0; i < posList.size(); i++) { GameObjectDAO data = posList.get(i); buffer.putInt(data.objectId); buffer.putDouble(data.x); buffer.putDouble(data.y); if (i < posList.size() - 1) { buffer.put((byte)31); } } buffer.put((byte)4); sendUdp(buffer.array()); }

Target:
public void sendUpdate(List<GameObjectDAO> posList) { try { Thread.sleep(20); } catch (InterruptedException e) { e.printStackTrace(); } ByteBuffer buffer = ByteBuffer.allocate(1024); buffer.order(ByteOrder.LITTLE_ENDIAN); buffer.put((byte)1); buffer.put((byte)Opcodes.POSITION_UPDATE.getValue()); buffer.put((byte)2); for (int i = 0; i < posList.size(); ++i) { GameObjectDAO data = posList.get(i); buffer.putInt(data.objectId); buffer.putDouble(data.x); buffer.putDouble(data.y); if (i < posList.size() - 1) { buffer.put((byte)31); } } buffer.put((byte)4); sendUdp(buffer.array()); }
Source:
public Encounter findEncounter(Visit visit, EncounterParameters encounterParameters) { EncounterType encounterType = encounterParameters.getEncounterType(); if (encounterType == null) { throw new IllegalArgumentException("Encounter Type not found"); } if (visit.getEncounters() != null) { for (Encounter encounter : visit.getEncounters()) { if (!encounter.isVoided() && (encounter.getUuid().equals(encounterParameters.getEncounterUuid()))) { return encounter; } } } return null; }

Target:
public Encounter findEncounter(Visit visit, EncounterParameters encounterParameters) { if (visit == null) { throw new IllegalArgumentException("visit is required"); } if (encounterParameters == null) { throw new IllegalArgumentException("encounterParameters are required"); } for (final Encounter encounter : visit.getNonVoidedEncounters()) { if (encounter.getUuid() .equals(encounterParameters.getEncounterUuid())) { return encounter; } } return null; }