auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private void createDiskBasedOnImage() { AddImageFromScratchParameters parameters = new AddImageFromScratchParameters(Guid.Empty, getParameters().getVmId(), (DiskImage) getParameters().getDiskInfo()); parameters.setQuotaId(getParameters().getQuotaId()); parameters.setStorageDomainId(getStorageDomainId().getValue()); parameters.setParentCommand(VdcActionType.AddDisk); parameters.setEntityId(getParameters().getEntityId()); parameters.setStoragePoolId(getStorageDomain().getstorage_pool_id().getValue()); getParameters().getImagesParameters().add(parameters); parameters.setParentParemeters(getParameters()); if (getVm() != null) { setVmSnapshotIdForDisk(parameters); VmDeviceUtils.addManagedDevice(new VmDeviceId(getParameters().getDiskInfo().getId(), getVmId()), VmDeviceType.DISK, VmDeviceType.DISK, null, true, false, ""); } VdcReturnValueBase tmpRetValue = Backend.getInstance().runInternalAction(VdcActionType.AddImageFromScratch, parameters, ExecutionHandler.createDefaultContexForTasks(getExecutionContext())); getReturnValue().getTaskIdList().addAll(tmpRetValue.getInternalTaskIdList()); if (tmpRetValue.getActionReturnValue() != null) { DiskImage diskImage = (DiskImage) tmpRetValue.getActionReturnValue(); addDiskPermissions(diskImage); getReturnValue().setActionReturnValue(diskImage.getId()); } getReturnValue().setFault(tmpRetValue.getFault()); setSucceeded(tmpRetValue.getSucceeded()); }

Target:
private void createDiskBasedOnImage() { AddImageFromScratchParameters parameters = new AddImageFromScratchParameters(Guid.Empty, getParameters().getVmId(), (DiskImage) getParameters().getDiskInfo()); parameters.setQuotaId(getParameters().getQuotaId()); parameters.setStorageDomainId(getStorageDomainId().getValue()); parameters.setParentCommand(VdcActionType.AddDisk); parameters.setEntityId(getParameters().getEntityId()); parameters.setStoragePoolId(getStorageDomain().getstorage_pool_id().getValue()); getParameters().getImagesParameters().add(parameters); parameters.setParentParemeters(getParameters()); if (getVm() != null) { setVmSnapshotIdForDisk(parameters); VmDeviceUtils.addManagedDevice(new VmDeviceId(getParameters().getDiskInfo().getId(), getVmId()), VmDeviceType.DISK, VmDeviceType.DISK, null, true, false); } VdcReturnValueBase tmpRetValue = Backend.getInstance().runInternalAction(VdcActionType.AddImageFromScratch, parameters, ExecutionHandler.createDefaultContexForTasks(getExecutionContext())); getReturnValue().getTaskIdList().addAll(tmpRetValue.getInternalTaskIdList()); if (tmpRetValue.getActionReturnValue() != null) { DiskImage diskImage = (DiskImage) tmpRetValue.getActionReturnValue(); addDiskPermissions(diskImage); getReturnValue().setActionReturnValue(diskImage.getId()); } getReturnValue().setFault(tmpRetValue.getFault()); setSucceeded(tmpRetValue.getSucceeded()); }
Source:
public TreeExplorer.View addItem(final String uuid, final String parentsUuid, final String name, final IsWidget icon, final boolean isContainer, final boolean state, final OptionalInt index) { checkNotExist(uuid); final TreeItem.Type itemType = isContainer ? TreeItem.Type.CONTAINER : TreeItem.Type.ITEM; final TreeItem item = buildItem(uuid, name, icon, itemType); final TreeItem parent = tree.getItemByUuid(parentsUuid); parent.addItem(itemType, uuid, name, icon); index.ifPresent(ind -> { final int count = parent.getChildCount(); final LinkedList<TreeItem> children = IntStream.iterate(count - 2, i -> i - 1).limit(count - ind - 1) .mapToObj((IntFunction<TreeItem>) parent::getChild).collect(Collectors.toCollection(LinkedList::new)); if (!children.isEmpty()) { children.stream().forEachOrdered(parent::removeItem); Collections.reverse(children); children.stream().forEachOrdered(parent::addItem); } }); parent.setState(getState(state)); item.setState(getState(state)); return this; }

Target:
public TreeExplorer.View addItem(final String uuid, final String parentsUuid, final String name, final IsWidget icon, final boolean isContainer, final boolean state, final OptionalInt index) { checkNotExist(uuid); final TreeItem.Type itemType = isContainer ? TreeItem.Type.CONTAINER : TreeItem.Type.ITEM; final TreeItem item = buildItem(uuid, name, icon, itemType); final TreeItem parent = tree.getItemByUuid(parentsUuid); if (index.isPresent()) { parent.insertItem(item, index.getAsInt()); } else { parent.addItem(item); } parent.setState(getState(state)); item.setState(getState(state)); return this; }
Source:
public Future<?> execute(final Runnable callback) { int numRetries = MAX_NUM_RETRIES; while (true) { try { if (!syncInit && numRetries == 0) { break; } callback.run(); break; } catch (Exception e) { try { numRetries --; units.sleep(interval); } catch (InterruptedException e1) { Thread.currentThread().interrupt(); return Futures.immediateFailure(e); } } } return executor.scheduleWithFixedDelay(new Runnable() { @Override public void run() { try { callback.run(); } catch (Exception e) { LOG.warn("Failed to load properties", e); } } }, interval, interval, units); }

Target:
public Future<?> execute(final Runnable callback) { while (true) { try { callback.run(); break; } catch (Exception e) { try { LOG.warn("Fail to poll the polling source", e); units.sleep(interval); } catch (InterruptedException e1) { Thread.currentThread().interrupt(); return Futures.immediateFailure(e); } } } return executor.scheduleWithFixedDelay(new Runnable() { @Override public void run() { try { callback.run(); } catch (Exception e) { LOG.warn("Failed to load properties", e); } } }, interval, interval, units); }
Source:
public String render(final GetCacheStateResult obj) { this.filesystemList = obj.getResult(); if ((this.filesystemList == null) || (Guard.isNullOrEmpty(this.filesystemList)) ){ return "No Cache Filesystems reported."; } initTable(ImmutableList.of("Path", "Available Capacity", "Used Capacity", "Unavailable Capacity", "Total Capacity", "Max Capacity", "Auto Reclaim Threshold", "Burst Threshold", "Max Utilization", "ID", "Node ID")); return ASCIITable.getInstance().getTable(getHeaders(), formatTableContents()); }

Target:
public String render(final GetCacheStateResult obj) { this.filesystemList = obj.getResult(); if (Guard.isNullOrEmpty(this.filesystemList)){ return "No Cache Filesystems reported."; } initTable(ImmutableList.of("Path", "Available Capacity", "Used Capacity", "Unavailable Capacity", "Total Capacity", "Max Capacity", "Auto Reclaim Threshold", "Burst Threshold", "Max Utilization", "ID", "Node ID")); return ASCIITable.getInstance().getTable(getHeaders(), formatTableContents()); }
Source:
public int getFrameTime() { String saved = TheApp.getCurrentVersionPreferences().get("FrameRate", String.valueOf(frameRate)); if (saved!= null) frameRate = Integer.parseInt(saved); TheApp.getCurrentVersionPreferences().put("FrameRate", String.valueOf(frameRate)); return frameRate; }

Target:
public int getFrameTime() { String saved = TheApp.getCurrentVersionPreferences().get("Internal.FrameRate", String.valueOf(frameRate)); if (saved!= null) frameRate = Integer.parseInt(saved); TheApp.getCurrentVersionPreferences().put("Internal.FrameRate", String.valueOf(frameRate)); return frameRate; }
Source:
public void process(Element elm, JID actorJID, IQ reqIQ, Element rsm) throws Exception { request = reqIQ; String node = elm.attributeValue(XMLConstants.NAME_ELEM); if (null == node) { createExtendedErrorReply(PacketError.Type.modify, PacketError.Condition.bad_request, XMLConstants.NODE_ID_REQUIRED); outQueue.put(response); return; } if (-1 == node.indexOf("@")) { specialItems.process(elm, actorJID, reqIQ, rsm); return; } userItems.process(elm, actorJID, reqIQ, rsm); }

Target:
public void process(Element elm, JID actorJID, IQ reqIQ, Element rsm) throws Exception { request = reqIQ; String node = elm.attributeValue(XMLConstants.NODE_ATTR); if (null == node) { createExtendedErrorReply(PacketError.Type.modify, PacketError.Condition.bad_request, XMLConstants.NODE_ID_REQUIRED); outQueue.put(response); return; } if (-1 == node.indexOf("@")) { specialItems.process(elm, actorJID, reqIQ, rsm); return; } userItems.process(elm, actorJID, reqIQ, rsm); }
Source:
public void testGetUriByFilenameFindsResourceRelativeToRootClasspath() throws Exception { final String filename = "commonutil/InputCommonUtilTest_resource.txt"; final URI uri = CommonUtil.getUriByFilename(filename); assertThat("URI is null for: " + filename, uri, is(not(nullValue()))); assertThat("URI contains com/puppycrawl/tools/checkstyle/utils", uri.toString(), not(containsString("com/puppycrawl/tools/checkstyle/utils"))); final ByteArrayOutputStream out = new ByteArrayOutputStream(); try (InputStream in = uri.toURL().openStream()) { IOUtils.copy(in, out); } assertThat("Content mismatches for: " + uri, new String(out.toByteArray(), StandardCharsets.UTF_8), startsWith("good")); }

Target:
public void testGetUriByFilenameFindsResourceRelativeToRootClasspath() throws Exception { final String filename = getPackageLocation() + "/InputCommonUtilTest_resource.txt"; final URI uri = CommonUtil.getUriByFilename(filename); assertThat("URI is null for: " + filename, uri, is(not(nullValue()))); final String uriRelativeToPackage = "com/puppycrawl/tools/checkstyle/utils/" + getPackageLocation() + "/InputCommonUtilTest_resource.txt"; assertThat("URI is relative to package " + uriRelativeToPackage, uri.toString(), not(containsString(uriRelativeToPackage))); final String content = IOUtils.toString(uri.toURL(), StandardCharsets.UTF_8); assertThat("Content mismatches for: " + uri, content, startsWith("good")); }
Source:
static Task generateFromTestGroup(JParallelTestsGroup jParallelTestsGroup, boolean monitoringEnabled) { CompositeTask compositeTask = new CompositeTask(); compositeTask.setLeading(new ArrayList<>()); compositeTask.setAttendant(new ArrayList<>()); compositeTask.setNumber(++number); compositeTask.setName(jParallelTestsGroup.getId() + "-group"); for (JLoadTest test : jParallelTestsGroup.getTests()) { WorkloadTask task = generateFromTest(test); task.setNumber(number); if (task.getTerminateStrategyConfiguration() instanceof InfiniteTerminationStrategyConfiguration) { compositeTask.getAttendant().add(task); } else { compositeTask.getLeading().add(task); } } if (monitoringEnabled) { MonitoringTask attendantMonitoring = new MonitoringTask(number, jParallelTestsGroup.getId() + " --- monitoring", jParallelTestsGroup.getId(), new InfiniteDuration()); compositeTask.getAttendant().add(attendantMonitoring); } return compositeTask; }

Target:
static Task generateFromTestGroup(JParallelTestsGroup jParallelTestsGroup, boolean monitoringEnabled) { CompositeTask compositeTask = new CompositeTask(); compositeTask.setLeading(new ArrayList<>()); compositeTask.setAttendant(new ArrayList<>()); compositeTask.setNumber(++number); compositeTask.setName(jParallelTestsGroup.getId() + "-group"); for (JLoadTest test : jParallelTestsGroup.getTests()) { WorkloadTask task = generateFromTest(test); task.setNumber(compositeTask.getNumber()); if (task.getTerminateStrategyConfiguration() instanceof InfiniteTerminationStrategyConfiguration) { compositeTask.getAttendant().add(task); } else { compositeTask.getLeading().add(task); } } if (monitoringEnabled) { MonitoringTask attendantMonitoring = new MonitoringTask(compositeTask.getNumber(), jParallelTestsGroup.getId() + " --- monitoring", jParallelTestsGroup.getId(), new InfiniteDuration()); compositeTask.getAttendant().add(attendantMonitoring); } return compositeTask; }
Source:
private Result<Subscription> createSubscriptionInternal(final SubscriptionBase subscriptionBase, final Client client) throws InternalNakadiException, DuplicatedSubscriptionException, ServiceUnavailableException { final Map<String, Optional<EventType>> eventTypeMapping = subscriptionBase.getEventTypes().stream() .collect(Collectors.toMap(Function.identity(), Try.wrap(eventTypeRepository::findByNameO).andThen(Try::getOrThrow))); final List<String> missingEventTypes = eventTypeMapping.entrySet().stream() .filter(entry -> !entry.getValue().isPresent()) .map(Map.Entry::getKey) .collect(Collectors.toList()); if (!missingEventTypes.isEmpty()) { final Problem problem = Problem.valueOf(MoreStatus.UNPROCESSABLE_ENTITY, createMissingEventsErrorMessage(missingEventTypes)); return Result.problem(problem); } eventTypeMapping.values().stream() .filter(Optional::isPresent) .map(Optional::get) .forEach(eventType -> client.checkScopes(eventType.getReadScopes())); if (featureToggleService.isFeatureEnabled(DISABLE_SUBSCRIPTION_CREATION)) { try { return Result.ok(getExistingSubscription(subscriptionBase)); } catch (final NoSuchSubscriptionException e) { throw new ServiceUnavailableException("Subscription creation is temporarily unavailable", e); } } final Subscription subscription = subscriptionRepository.createSubscription(subscriptionBase); return Result.ok(subscription); }

Target:
private Result<Subscription> createSubscriptionInternal(final SubscriptionBase subscriptionBase, final Client client) throws InternalNakadiException, DuplicatedSubscriptionException, ServiceUnavailableException { final Map<String, Optional<EventType>> eventTypeMapping = subscriptionBase.getEventTypes().stream() .collect(Collectors.toMap(Function.identity(), Try.wrap(eventTypeRepository::findByNameO).andThen(Try::getOrThrow))); final List<String> missingEventTypes = eventTypeMapping.entrySet().stream() .filter(entry -> !entry.getValue().isPresent()) .map(Map.Entry::getKey) .collect(Collectors.toList()); if (!missingEventTypes.isEmpty()) { final Problem problem = Problem.valueOf(MoreStatus.UNPROCESSABLE_ENTITY, createMissingEventsErrorMessage(missingEventTypes)); return Result.problem(problem); } eventTypeMapping.values().stream() .filter(Optional::isPresent) .map(Optional::get) .forEach(eventType -> client.checkScopes(eventType.getReadScopes())); final Subscription subscription = subscriptionRepository.createSubscription(subscriptionBase); return Result.ok(subscription); }
Source:
protected boolean createVirtualenv(File virtualEnvDir) { CLog.d("Creating virtualenv at " + virtualEnvDir); String[] cmd = new String[] { "virtualenv", "-p", "python" + mPythonVersion, virtualEnvDir.getAbsolutePath()}; long waitRetryCreate = 5 * SECOND_IN_MSECS; for (int try_count = 0; try_count < PIP_RETRY + 1; try_count++) { if (try_count > 0) { getRunUtil().sleep(waitRetryCreate); } CommandResult c = getRunUtil().runTimedCmd(10 * MINUTE_IN_MSECS, cmd); if (!CommandStatus.SUCCESS.equals(c.getStatus())) { String message_lower = (c.getStdout() + c.getStderr()).toLowerCase(); if (message_lower.contains("errno 26") || message_lower.contains("text file busy")) { CLog.e("detected the virtualenv path is being created by other process."); } else { CLog.e("Exit code: %s, stdout: %s, stderr: %s", c.getStatus(), c.getStdout(), c.getStderr()); break; } } else { CLog.d("Successfully created virtualenv at " + virtualEnvDir); return true; } } return false; }

Target:
protected boolean createVirtualenv(File virtualEnvDir) { CLog.d("Creating virtualenv at " + virtualEnvDir); String[] cmd = new String[] { "virtualenv", "-p", "python" + mPythonVersion, virtualEnvDir.getAbsolutePath()}; long waitRetryCreate = 5 * SECOND_IN_MSECS; for (int try_count = 0; try_count < PIP_RETRY + 1; try_count++) { if (try_count > 0) { getRunUtil().sleep(waitRetryCreate); } CommandResult c = getRunUtil().runTimedCmd( mVirtualEnvInstallationWaitTimeMinutes * MINUTE_IN_MSECS, cmd); if (!CommandStatus.SUCCESS.equals(c.getStatus())) { String message_lower = (c.getStdout() + c.getStderr()).toLowerCase(); if (message_lower.contains("errno 26") || message_lower.contains("text file busy")) { CLog.e("detected the virtualenv path is being created by other process."); } else { CLog.e("Exit code: %s, stdout: %s, stderr: %s", c.getStatus(), c.getStdout(), c.getStderr()); break; } } else { CLog.d("Successfully created virtualenv at " + virtualEnvDir); return true; } } return false; }
Source:
public void testBadClient() throws Exception { MQTT mqtt = createMQTTConnection(); mqtt.setClientId(""); mqtt.setCleanSession(true); BlockingConnection connection = mqtt.blockingConnection(); connection.connect(); try { connection = mqtt.blockingConnection(); connection.connect(); fail("second connection shouldn't be allowed"); } catch (Exception e) { } NettyAcceptor acceptor = (NettyAcceptor) server.getRemotingService().getAcceptor("MQTT"); assertEquals(1, acceptor.getConnections().size()); RemotingConnection conn = server.getRemotingService().getConnections().iterator().next(); assertTrue(conn instanceof MQTTConnection); conn.fail(new ActiveMQException("testBadClient")); assertEquals("Server connection not cleaned up!", 0, acceptor.getConnections().size()); connection = mqtt.blockingConnection(); connection.connect(); connection.disconnect(); }

Target:
public void testBadClient() throws Exception { MQTT mqtt = createMQTTConnection(); mqtt.setClientId(""); mqtt.setCleanSession(true); BlockingConnection connection = mqtt.blockingConnection(); connection.connect(); try { connection = mqtt.blockingConnection(); connection.connect(); fail("second connection shouldn't be allowed"); } catch (Exception e) { } NettyAcceptor acceptor = (NettyAcceptor) server.getRemotingService().getAcceptor("MQTT"); assertEquals(1, acceptor.getConnections().size()); RemotingConnection conn = server.getRemotingService().getConnections().iterator().next(); assertTrue(conn instanceof MQTTConnection); conn.fail(new ActiveMQException("testBadClient")); Wait.assertEquals(0, ()->acceptor.getConnections().size()); connection = mqtt.blockingConnection(); connection.connect(); connection.disconnect(); }
Source:
public JHttpResponse execute(JHttpEndpoint endpoint, JHttpQuery query) { setRestTemplateParamsForQuery(query); URI endpointURI = endpoint.getURI(query.getQueryParams()); if (endpoint.getProtocol() == HTTPS) { restTemplate.setRequestFactory(getSslAllTrustRequestFactory()); } RequestEntity requestEntity = mapToRequestEntity(query, endpointURI); ResponseEntity responseEntity = restTemplate.exchange(endpointURI, query.getMethod(), requestEntity, Object.class); restoreDefaultRestTemplateParams(); return mapToJHttpResponse(responseEntity); }

Target:
public JHttpResponse execute(JHttpEndpoint endpoint, JHttpQuery query) { URI endpointURI = endpoint.getURI(query.getPath(), query.getQueryParams()); RequestEntity requestEntity = mapToRequestEntity(query, endpointURI); ResponseEntity responseEntity; if (query.getResponseBodyType() != null) { responseEntity = restTemplate.exchange(endpointURI, query.getMethod(), requestEntity, query.getResponseBodyType()); } else { responseEntity = restTemplate.exchange(endpointURI, query.getMethod(), requestEntity, byte[].class); } return mapToJHttpResponse(responseEntity); }
Source:
protected List<String[]> getOriginalTablesWithSchema(Connection connection, String schema) { try (ResultSet resultSet = getTables(connection, schema, null)) { ImmutableList.Builder<String[]> list = ImmutableList.builder(); String[] arr; while (resultSet.next()) { String schemaName = resultSet.getString("TABLE_SCHEM"); String tableName = resultSet.getString("TABLE_NAME"); arr = new String[] {schemaName, tableName}; list.add(arr); } return list.build(); } catch (SQLException e) { throw new PrestoException(JDBC_ERROR, e); } }

Target:
protected List<CaseSensitiveMappedSchemaTableName> getOriginalTablesWithSchema(Connection connection, String schema) { try (ResultSet resultSet = getTables(connection, schema, null)) { ImmutableList.Builder<CaseSensitiveMappedSchemaTableName> list = ImmutableList.builder(); while (resultSet.next()) { String schemaName = resultSet.getString("TABLE_SCHEM"); String tableName = resultSet.getString("TABLE_NAME"); list.add(new CaseSensitiveMappedSchemaTableName(schemaName, tableName)); } return list.build(); } catch (SQLException e) { throw new PrestoException(JDBC_ERROR, e); } }
Source:
public void onStateUpdateFromItem(State state) { logger.debug("State update from item: '{}'", state); callback.handleCommand((Command) applyOffset(state, false)); }

Target:
public void onStateUpdateFromItem(State state) { callback.handleCommand((Command) applyOffset(state, false)); }
Source:
public Optional<Shape> getShapeAt(final double x, final double y) { return null; }

Target:
public Optional<Shape> getShapeAt(final double x, final double y) { return Optional.empty(); }
Source:
public static InputStream openInputStream(String path) throws IOException { final InputStream inputStream; if (path.startsWith("http:") || path.startsWith("https:") || path.startsWith("ftp:")) { inputStream = getURLHelper(new URL(path)).openInputStream(); } else if (IOUtil.hasScheme(path)) { inputStream = Files.newInputStream(IOUtil.getPath(path)); } else { File file = new File(path); inputStream = new FileInputStream(file); } return inputStream; }

Target:
public static InputStream openInputStream(String path) throws IOException { return openInputStream(path, null); }
Source:
public void shouldGetPixelsFromAnyNonNullableCreatedBitmap() { Bitmap bitmap; int width = 10; int height = 10; int[] pixels = new int[width * height]; bitmap = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888); bitmap.getPixels(pixels, 0, width, 0, 0, width, height); assertThat(pixels).isNotNull(); bitmap = Bitmap.createBitmap(bitmap); bitmap.getPixels(pixels, 0, width, 0, 0, width, height); assertThat(pixels).isNotNull(); bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height); bitmap.getPixels(pixels, 0, width, 0, 0, width, height); assertThat(pixels).isNotNull(); bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, new Matrix(), false); bitmap.getPixels(pixels, 0, width, 0, 0, width, height); assertThat(pixels).isNotNull(); bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); bitmap.getPixels(pixels, 0, width, 0, 0, width, height); assertThat(pixels).isNotNull(); bitmap = Bitmap.createBitmap(pixels, width, height, Bitmap.Config.ARGB_8888); bitmap.getPixels(pixels, 0, width, 0, 0, width, height); assertThat(pixels).isNotNull(); }

Target:
public void shouldGetPixelsFromAnyNonNullableCreatedBitmap() { Bitmap bitmap; int width = 10; int height = 10; int[] pixels = new int[width * height]; bitmap = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888); bitmap.getPixels(pixels, 0, width, 0, 0, width, height); bitmap = Bitmap.createBitmap(bitmap); bitmap.getPixels(pixels, 0, width, 0, 0, width, height); bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height); bitmap.getPixels(pixels, 0, width, 0, 0, width, height); bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, new Matrix(), false); bitmap.getPixels(pixels, 0, width, 0, 0, width, height); bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); bitmap.getPixels(pixels, 0, width, 0, 0, width, height); bitmap = Bitmap.createBitmap(pixels, width, height, Bitmap.Config.ARGB_8888); bitmap.getPixels(pixels, 0, width, 0, 0, width, height); }
Source:
public void enrichDiskByJsonDescription(String jsonDiskDescription, Disk disk) throws IOException, DecoderException { Map<String, Object> diskDescriptionMap = JsonHelper.jsonToMap(jsonDiskDescription); String encodingStr = (String) diskDescriptionMap.get(DISK_ENCODING); if (encodingStr != null) { int encoding = Integer.parseInt(encodingStr); for (int priority = 0; priority < DESCRIPTION_FIELDS_PRIORITY.length; ++priority) { if (((priority + 1) & encoding) != 0) { String fieldName = DESCRIPTION_FIELDS_PRIORITY[priority]; String fieldValue = (String) diskDescriptionMap.get(fieldName); diskDescriptionMap.put(fieldName, decodeDiskProperty(fieldValue)); } } } disk.setDiskAlias((String) diskDescriptionMap.get(DISK_ALIAS)); disk.setDiskDescription((String) diskDescriptionMap.get(DISK_DESCRIPTION)); }

Target:
public void enrichDiskByJsonDescription(String jsonDiskDescription, Disk disk) throws IOException, DecoderException { Map<String, Object> diskDescriptionMap = JsonHelper.jsonToMap(jsonDiskDescription); String encodingStr = (String) diskDescriptionMap.get(DISK_ENCODING); if (encodingStr != null) { int encoding = Integer.parseInt(encodingStr); for (int priority = 0; priority < DESCRIPTION_FIELDS_PRIORITY.length; ++priority) { if (((1 << priority) & encoding) != 0) { String fieldName = DESCRIPTION_FIELDS_PRIORITY[priority]; String fieldValue = (String) diskDescriptionMap.get(fieldName); diskDescriptionMap.put(fieldName, decodeDiskProperty(fieldValue)); } } } disk.setDiskAlias((String) diskDescriptionMap.get(DISK_ALIAS)); disk.setDiskDescription((String) diskDescriptionMap.get(DISK_DESCRIPTION)); }
Source:
public boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator, TimeRange timeRange, Mutation mutation) throws IOException { checkMutationType(mutation); checkRow(mutation, row); return doCheckAndRowMutate(row, family, qualifier, op, comparator, null, timeRange, null, mutation); }

Target:
public boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator, TimeRange timeRange, Mutation mutation) throws IOException { return doCheckAndRowMutate(row, family, qualifier, op, comparator, null, timeRange, null, mutation); }
Source:
private void updateFromCheckpoint(LogData entry, boolean initialize) { UUID streamId = entry.getCheckpointedStreamId(); long lastUpdateToStream = entry.getCheckpointedStreamStartLogAddress(); if (Address.isAddress(lastUpdateToStream)) { long currentStreamTail = streamTails.getOrDefault(streamId, Address.NON_ADDRESS); long newTail = Math.max(currentStreamTail, lastUpdateToStream); streamTails.put(streamId, newTail); if (initialize) { END record we can use this info to compute the stream trim mark, if (entry.getCheckpointType() == CheckpointEntry.CheckpointEntryType.END) { streamsAddressSpaceMap.compute(streamId, (id, addressSpace) -> { if (addressSpace == null) { return new StreamAddressSpace(lastUpdateToStream, new Roaring64NavigableMap()); } addressSpace.setTrimMark(Long.max(addressSpace.getTrimMark(), lastUpdateToStream)); return addressSpace; }); } } else { if (!streamsAddressSpaceMap.containsKey(streamId)) { Roaring64NavigableMap addressMap = new Roaring64NavigableMap(); addressMap.addLong(newTail); streamsAddressSpaceMap.put(streamId, new StreamAddressSpace(Address.NON_EXIST, addressMap)); } } } }

Target:
private void updateFromCheckpoint(LogData entry, boolean initialize) { UUID streamId = entry.getCheckpointedStreamId(); long lastUpdateToStream = entry.getCheckpointedStreamStartLogAddress(); if (Address.isAddress(lastUpdateToStream)) { long currentStreamTail = streamTails.getOrDefault(streamId, Address.NON_ADDRESS); streamTails.put(streamId, Math.max(currentStreamTail, lastUpdateToStream)); if (initialize) { END record we can use this info to compute the stream trim mark, if (entry.getCheckpointType() == CheckpointEntry.CheckpointEntryType.END) { streamsAddressSpaceMap.compute(streamId, (id, addressSpace) -> { if (addressSpace == null) { return new StreamAddressSpace(lastUpdateToStream, new Roaring64NavigableMap()); } addressSpace.setTrimMark(Long.max(addressSpace.getTrimMark(), lastUpdateToStream)); return addressSpace; }); } } } }
Source:
private void handleForwardMerge(DiskImage topImage, DiskImage baseImage, DiskImage imageFromVdsm) { topImage.setVolumeFormat(baseImage.getVolumeFormat()); topImage.setVolumeType(baseImage.getVolumeType()); topImage.setParentId(baseImage.getParentId()); getDestinationDiskImage().setSize(baseImage.getSize()); getDestinationDiskImage().setActualSizeInBytes(getImageInfoFromVdsm(getDestinationDiskImage()).getActualSizeInBytes()); baseDiskDao.update(topImage); imageDao.update(topImage.getImage()); updateDiskImageDynamic(imageFromVdsm, topImage); updateVmConfigurationForImageChange(getDestinationDiskImage().getImage().getSnapshotId(), getDestinationDiskImage().getImageId(), getDestinationDiskImage()); }

Target:
private void handleForwardMerge(DiskImage topImage, DiskImage baseImage, DiskImage imageFromVdsm) { topImage.setVolumeFormat(baseImage.getVolumeFormat()); topImage.setVolumeType(baseImage.getVolumeType()); topImage.setParentId(baseImage.getParentId()); getDestinationDiskImage().setSize(baseImage.getSize()); getDestinationDiskImage().setActualSizeInBytes(getImageInfoFromVdsm(getDestinationDiskImage()).getActualSizeInBytes()); baseDiskDao.update(topImage); imageDao.update(topImage.getImage()); updateDiskImageDynamic(imageFromVdsm, topImage); removeTopImageMemoryIfNeeded(topImage); updateVmConfigurationForImageChange(getDestinationDiskImage().getImage().getSnapshotId(), getDestinationDiskImage().getImageId(), getDestinationDiskImage()); }
Source:
public Future<?> closeAsync() { if (executor.inEventLoop()) { return close0(); } else { return executor.submit(new Runnable() { @Override public void run() { close0(); } }).awaitUninterruptibly(); } }

Target:
public Future<Void> closeAsync() { if (executor.inEventLoop()) { return close0(); } else { final Promise<Void> closeComplete = executor.newPromise(); executor.execute(new Runnable() { @Override public void run() { close0().addListener(new FutureListener<Void>() { @Override public void operationComplete(Future<Void> f) throws Exception { if (f.isSuccess()) { closeComplete.setSuccess(null); } else { closeComplete.setFailure(f.cause()); } } }); } }); return closeComplete; } }
Source:
public Response remove() { get(); RemoveDiskParameters parameters = new RemoveDiskParameters(); parameters.setDiskId(guid); return performAction(VdcActionType.RemoveDisk, parameters); }

Target:
public Response remove() { get(); return performAction(VdcActionType.RemoveDisk, new RemoveDiskParameters(guid)); }
Source:
private FormatableBitSet getDefaultValueMap(ExecRow defaultValueRow) throws StandardException { FormatableBitSet defaultValueMap = null; int size = 0; for (int i = 0; i < defaultValueRow.nColumns(); ++i) { if (!defaultValueRow.getColumn(i+1).isNull()) size++; } int index = 0; if (size > 0) { defaultValueMap = new FormatableBitSet(size); for (int i = 0; i < defaultValueRow.nColumns(); ++i) { if (!defaultValueRow.getColumn(i+1).isNull()) { defaultValueMap.set(index); } index++; } } return defaultValueMap; }

Target:
private FormatableBitSet getDefaultValueMap(ExecRow defaultValueRow) throws StandardException { FormatableBitSet defaultValueMap = null; int size = defaultValueRow.size(); int index = 0; if (size > 0) { defaultValueMap = new FormatableBitSet(size); for (int i = 0; i < defaultValueRow.nColumns(); ++i) { if (defaultValueRow.getColumn(i+1) != null && !defaultValueRow.getColumn(i+1).isNull()) { defaultValueMap.set(index); } index++; } } return defaultValueMap; }
Source:
protected final Path getRelativeDirectory() { SnomedRF2Folder folder = SnomedRefSetUtil.REFSET_TYPE_TO_FOLDER_MAP.get(refSetType); if (folder != null) { if (refSetType == SnomedRefSetType.OWL_AXIOM) { return Paths.get(releaseType.toString(), SnomedRF2Folder.TERMINOLOGY.getDisplayName()); } else { return Paths.get(releaseType.toString(), SnomedRF2Folder.REFSET.getDisplayName(), folder.getDisplayName()); } } throw new IllegalArgumentException("Unknown SNOMED CT reference set type: " + refSetType); }

Target:
protected final Path getRelativeDirectory() { SnomedRF2Folder folder = SnomedRefSetUtil.REFSET_TYPE_TO_FOLDER_MAP.get(refSetType); if (folder != null) { if (refSetType == SnomedRefSetType.OWL_AXIOM || refSetType == SnomedRefSetType.OWL_ONTOLOGY) { return Paths.get(releaseType.toString(), SnomedRF2Folder.TERMINOLOGY.getDisplayName()); } else { return Paths.get(releaseType.toString(), SnomedRF2Folder.REFSET.getDisplayName(), folder.getDisplayName()); } } throw new IllegalArgumentException("Unknown SNOMED CT reference set type: " + refSetType); }
Source:
public void testInterruptsNotCached() throws Exception { ConnectionID connectionId = new ConnectionID(new InetSocketAddress(InetAddress.getLocalHost(), 8080), 0); AwaitingNettyClient nettyClient = new AwaitingNettyClient(); PartitionRequestClientFactory factory = new PartitionRequestClientFactory(nettyClient, 0); nettyClient.awaitForInterrupts = true; connectAndInterrupt(factory, connectionId); nettyClient.awaitForInterrupts = false; factory.createPartitionRequestClient(connectionId); }

Target:
public void testInterruptsNotCached() throws Exception { ConnectionID connectionId = new ConnectionID(new InetSocketAddress(InetAddress.getLocalHost(), 8080), 0); try (AwaitingNettyClient nettyClient = new AwaitingNettyClient()) { PartitionRequestClientFactory factory = new PartitionRequestClientFactory(nettyClient, 0); nettyClient.awaitForInterrupts = true; connectAndInterrupt(factory, connectionId); nettyClient.awaitForInterrupts = false; factory.createPartitionRequestClient(connectionId); } }
Source:
public void reportsExistence() throws IOException { final Bucket bucket = Mockito.mock(Bucket.class); final Ocket ocket = Mockito.mock(Ocket.class); Mockito.doReturn(true).when(ocket).exists(); final String label = "exists"; Mockito.doReturn(ocket).when(bucket).ocket(label); MatcherAssert.assertThat( new AwsDoc(bucket, label).exists(), Matchers.equalTo(ocket.exists()) ); }

Target:
public void reportsExistence() throws IOException { final String label = "exists"; final AwsDoc doc = this.createDoc(label, label); MatcherAssert.assertThat(doc.exists(), Matchers.equalTo(true)); }
Source:
public void testBlobEscape() throws Exception { assertThat(s3BlobStore.list(containerName)).isEmpty(); putBlobAndCheckIt("blob%"); PageSet<? extends StorageMetadata> res = s3BlobStore.list(containerName); Iterator<? extends StorageMetadata> iter = res.iterator(); StorageMetadata meta = iter.next(); assertThat(meta.getName()).isEqualTo("blob%"); assertThat(!iter.hasNext()); }

Target:
public void testBlobEscape() throws Exception { assertThat(s3BlobStore.list(containerName)).isEmpty(); putBlobAndCheckIt("blob%"); PageSet<? extends StorageMetadata> res = s3BlobStore.list(containerName); StorageMetadata meta = res.iterator().next(); assertThat(meta.getName()).isEqualTo("blob%"); assertThat(res).hasSize(1); }
Source:
public void testSetLteNoWifiAlt() { ImsCall mTestImsCall = new ImsCall(mContext, mTestCallProfile); assertFalse(mTestImsCall.isWifiCall()); assertFalse(mTestImsCall.getRadioTechnology() == ServiceState.RIL_RADIO_TECHNOLOGY_LTE); mBundle.putString(ImsCallProfile.EXTRA_CALL_RAT_TYPE_ALT, ServiceState.RIL_RADIO_TECHNOLOGY_LTE + ""); assertFalse(mTestImsCall.isWifiCall()); assertTrue(mTestImsCall.getRadioTechnology() == ServiceState.RIL_RADIO_TECHNOLOGY_LTE); }

Target:
public void testSetLteNoWifiAlt() { ImsCall mTestImsCall = new ImsCall(mContext, mTestCallProfile); assertFalse(mTestImsCall.isWifiCall()); assertNotEquals(mTestImsCall.getRadioTechnology(), ServiceState.RIL_RADIO_TECHNOLOGY_LTE); mBundle.putString(ImsCallProfile.EXTRA_CALL_RAT_TYPE_ALT, ServiceState.RIL_RADIO_TECHNOLOGY_LTE + ""); assertFalse(mTestImsCall.isWifiCall()); assertEquals(mTestImsCall.getRadioTechnology(), ServiceState.RIL_RADIO_TECHNOLOGY_LTE); }
Source:
public boolean isActivated() { return JenkinsLocationConfiguration.get().getUrl() == null; }

Target:
public boolean isActivated() { JenkinsLocationConfiguration loc = JenkinsLocationConfiguration.get(); return loc == null || (loc != null && loc.getUrl() == null); }
Source:
public OsgpMeterValue(final BigDecimal value, final OsgpUnit osgpUnit) { super(); this.value = value; this.osgpUnit = osgpUnit; }

Target:
public OsgpMeterValue(final BigDecimal value, final OsgpUnit osgpUnit) { this.value = value; this.osgpUnit = osgpUnit; }
Source:
public DateTime getFrom() { return from; }

Target:
public DateTime getFrom() { return this.from; }
Source:
void testDtoListResponses() { FlowJsonObjectReader reader = new FlowJsonObjectReader(); TypeReference<SurveyGroupDto> typeReference = new TypeReference<SurveyGroupDto>() {}; List<SurveyGroupDto> surveyList = null; try { surveyList = reader.readDtoListObject(DTO_LIST_JSON_OBJECT, typeReference); } catch (IOException e) { } assertNotEquals(surveyList, null); assertEquals(surveyList.size(), 1); assertEquals(surveyList.get(0).getName(),"1.10.36 all questions"); }

Target:
void testDtoListResponses() { FlowJsonObjectReader reader = new FlowJsonObjectReader(); TypeReference<SurveyGroupDto> typeReference = new TypeReference<SurveyGroupDto>() {}; List<SurveyGroupDto> surveyList = null; try { surveyList = reader.readDtoListObject(DTO_LIST_JSON_OBJECT, typeReference); } catch (IOException e) { } assertNotEquals(null, surveyList); assertEquals(1, surveyList.size()); assertEquals("1.10.36 all questions", surveyList.get(0).getName()); }
Source:
public ServoSubsystem(String name, boolean isInverted, Servo... servos) { super(name); this.isInverted = false; this.servos = servos; setInverted(isInverted); set(0); }

Target:
public ServoSubsystem(String name, boolean isInverted, Servo... servos) { super(name); this.servos = servos; this.isInverted = isInverted; set(0); }
Source:
public HashSet<ProcessDefinitionVariable> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { HashSet<ProcessDefinitionVariable> variables = new HashSet<ProcessDefinitionVariable>(); ObjectCodec oc = jp.getCodec(); JsonNode nodes = oc.readTree(jp); for (int i = 0; i < nodes.size(); i++) { ProcessDefinitionVariable variable = new ProcessDefinitionVariable(nodes.get(i) .get("variableName") .asText(), nodes.get(i) .get("variableType") .asText()); variables.add(variable); } return variables; }

Target:
public Set<ProcessDefinitionVariable> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { Set<ProcessDefinitionVariable> variables = new HashSet<ProcessDefinitionVariable>(); ObjectCodec oc = jp.getCodec(); JsonNode nodes = oc.readTree(jp); for (int i = 0; i < nodes.size(); i++) { ProcessDefinitionVariable variable = new ProcessDefinitionVariable(nodes.get(i) .get("variableName") .asText(), nodes.get(i) .get("variableType") .asText()); variables.add(variable); } return variables; }
Source:
private String getNativesResourcesFilePart() { return libraryNameMapper.mapLibraryName(SQLITE4JAVA).replace(".dylib", ".jnilib"); }

Target:
private String getNativesResourcesFilePart() { return getLibName().replace(".dylib", ".jnilib"); }
Source:
public void emit() { String src = group(1); String formatting = group(2); List<String> positional = new ArrayList<String>(); positional.add("alt"); positional.add("width"); positional.add("height"); Map<String, String> properties = getFormattingProperties(formatting, positional); if (!properties.containsKey("alt") || properties.get("alt").isEmpty()) { int end = src.lastIndexOf("."); if (end != -1) { String firstSrc = src.substring(0, end); int start = Math.max(firstSrc.lastIndexOf("/") + 1, 0); properties.put("alt", firstSrc.substring(start)); } else { properties.put("alt", src); } } if (group(0).startsWith("image::")) { Attributes imageblockattr = new Attributes(); imageblockattr.setCssClass("imageblock"); builder.beginBlock(BlockType.DIV, imageblockattr); Attributes contentattr = new Attributes(); contentattr.setCssClass("content"); builder.beginBlock(BlockType.DIV, contentattr); emitImage(builder, src, properties); builder.endBlock(); if (properties.containsKey("title")) { Attributes attr = new Attributes(); attr.setCssClass("title"); builder.beginBlock(BlockType.DIV, attr); if (properties.containsKey("caption")) { builder.characters(properties.get("caption")); } builder.characters(properties.get("title")); builder.endBlock(); } builder.endBlock(); } else { Attributes imageblockattr = new Attributes(); imageblockattr.setCssClass("image"); builder.beginSpan(SpanType.SPAN, imageblockattr); emitImage(builder, src, properties); builder.endSpan(); } }

Target:
public void emit() { String src = group(1); String formatting = group(2); List<String> positional = new ArrayList<>(); positional.add("alt"); positional.add("width"); positional.add("height"); Map<String, String> properties = getFormattingProperties(formatting, positional); if (!properties.containsKey("alt") || properties.get("alt").isEmpty()) { int end = src.lastIndexOf("."); if (end != -1) { String firstSrc = src.substring(0, end); int start = Math.max(firstSrc.lastIndexOf("/") + 1, 0); properties.put("alt", firstSrc.substring(start)); } else { properties.put("alt", src); } } if (group(0).startsWith("image::")) { Attributes imageSpanAttributes = new Attributes(); imageSpanAttributes.setCssClass("imageblock"); builder.beginBlock(BlockType.DIV, imageSpanAttributes); Attributes contentAttr = new Attributes(); contentAttr.setCssClass("content"); builder.beginBlock(BlockType.DIV, contentAttr); emitImage(builder, src, properties); builder.endBlock(); if (properties.containsKey("title")) { Attributes attr = new Attributes(); attr.setCssClass("title"); builder.beginBlock(BlockType.DIV, attr); if (properties.containsKey("caption")) { builder.characters(properties.get("caption")); } builder.characters(properties.get("title")); builder.endBlock(); } builder.endBlock(); } else { Attributes imageblockattr = new Attributes(); imageblockattr.setCssClass("image"); builder.beginSpan(SpanType.SPAN, imageblockattr); emitImage(builder, src, properties); builder.endSpan(); } }
Source:
public void setItem(ItemStack is) { if (is == null) { is = new ItemStack(Material.AIR, 1); } is.setAmount(1); metadata.set(MetadataIndex.ITEM_FRAME_ITEM, is); setRotation(Rotation.NONE); }

Target:
public void setItem(ItemStack is) { is = InventoryUtil.itemOrEmpty(is).clone(); is.setAmount(1); metadata.set(MetadataIndex.ITEM_FRAME_ITEM, is); setRotation(Rotation.NONE); }
Source:
public static TransactionStatus fromDBObject(DBObject dbo) { TransactionStateType status = TransactionStateType.valueOf(TranslatorUtils.toString(dbo, STATUS_KEY)); String message = TranslatorUtils.toString(dbo, MESSAGE_KEY); Optional<Iterable<FragmentReportType>> fragmentReports = TranslatorUtils.toIterable(dbo, FRAGMENT_REPORTS_KEY, FragmentReportTranslator.fromDBObject()); if (fragmentReports.isPresent()) { return new TransactionStatus(status, message, fragmentReports.get()); } else { return new TransactionStatus(status, message); } }

Target:
public static TransactionStatus fromDBObject(DBObject dbo) { TransactionStateType status = TransactionStateType.valueOf(TranslatorUtils.toString(dbo, STATUS_KEY)); String message = TranslatorUtils.toString(dbo, MESSAGE_KEY); Optional<Iterable<FragmentReportType>> fragmentReports = TranslatorUtils.toIterable( dbo, FRAGMENT_REPORTS_KEY, FragmentReportTranslator.fromDBObject() ); return new TransactionStatus(status, message, fragmentReports.orNull()); }
Source:
public void appendAll(Collection<StreamInputPacketIndexEntry> preParsedIndex) throws CTFReaderException { for (ICTFPacketInformation sipie : preParsedIndex) { append(checkNotNull(sipie)); } }

Target:
public void appendAll(Collection<StreamInputPacketIndexEntry> preParsedIndex) throws CTFException { for (ICTFPacketInformation sipie : preParsedIndex) { append(checkNotNull(sipie)); } }
Source:
public boolean matches(Object item) { boolean found = false; @SuppressWarnings("unchecked") Set<Feature> features = (Set<Feature>) item; for (Feature f : features) { if (f.name().equals(feature.name())) { found = true; break; } } return found; }

Target:
public boolean matches(Object item) { @SuppressWarnings("unchecked") Set<Feature> features = (Set<Feature>) item; for (Feature f : features) { if (f.name().equals(feature.name())) { return true; } } return false; }
Source:
public String loadContextSpecificPage(Model model, HttpSession session) { Member member = (Member) session.getAttribute("member"); if (member == null) { return "redirect:../denied"; } UserType context = member.getContext(); if (context == UserType.PLAYER) { return "redirect:../profile"; } else if (context == UserType.OFFICIAL) { return "redirect:../official"; } else if (context == UserType.COORDINATOR) { return "redirect:../coordinator"; } else { return "redirect:../admin"; } }

Target:
public String loadContextSpecificPage(Model model, HttpSession session) { Member member = (Member) session.getAttribute("member"); if (member == null) { return "redirect:/denied"; } UserType context = member.getContext(); if (context == UserType.PLAYER) { return "redirect:/profile"; } else if (context == UserType.OFFICIAL) { return "redirect:/official"; } else if (context == UserType.COORDINATOR) { return "redirect:/coordinator"; } else { return "redirect:/admin"; } }
Source:
public static SubjectEntity[] getStorageEntities(List<CinderDisk> cinderDisks) { Set<SubjectEntity> storageSubjects = new HashSet<>(); for (final CinderDisk cinderDisk : cinderDisks) { SubjectEntity se = new SubjectEntity(VdcObjectType.Storage, cinderDisk.getStorageIds().get(0)); storageSubjects.add(se); } return storageSubjects.toArray(new SubjectEntity[storageSubjects.size()]); }

Target:
public static SubjectEntity[] getStorageEntities(List<CinderDisk> cinderDisks) { Set<SubjectEntity> storageSubjects = new HashSet<>(); for (CinderDisk cinderDisk : cinderDisks) { SubjectEntity se = new SubjectEntity(VdcObjectType.Storage, cinderDisk.getStorageIds().get(0)); storageSubjects.add(se); } return storageSubjects.toArray(new SubjectEntity[storageSubjects.size()]); }
Source:
public void fetchLastAccessed(final LastAccessManagerCallback callback, final View view, final String courseId){ try{ if(!callback.isFetchingLastAccessed()) { if(courseId!=null && getProfile()!=null && getProfile().username!=null){ String prefName = PrefManager.getPrefNameForLastAccessedBy(getProfile() .username, courseId); final PrefManager prefManager = new PrefManager(MainApplication.instance(), prefName); final String prefModuleId = prefManager.getLastAccessedSubsectionId(); logger.debug("Last Accessed Module ID from Preferences " +prefModuleId); callback.showLastAccessedView(prefModuleId, courseId, null); GetLastAccessedTask getLastAccessedTask = new GetLastAccessedTask(MainApplication.instance()) { @Override public void onFinish(SyncLastAccessedSubsectionResponse result) { String server_moduleId = null; if(result!=null && result.getLastVisitedModuleId()!=null){ server_moduleId = result.getLastVisitedModuleId(); logger.debug("Last Accessed Module ID from Server Get " +server_moduleId); if(prefManager.isSyncedLastAccessedSubsection()){ prefManager.putLastAccessedSubsection(server_moduleId, true); callback.showLastAccessedView(server_moduleId, courseId, null); }else{ if(prefModuleId!=null && prefModuleId.length()>0){ syncLastAccessedWithServer(prefManager, view, courseId, prefModuleId, callback); } } }else{ if(prefModuleId!=null && prefModuleId.length()>0){ syncLastAccessedWithServer(prefManager, view, courseId, prefModuleId, callback); } } callback.setFetchingLastAccessed( false ); } @Override public void onException(Exception ex) { callback.setFetchingLastAccessed( false ); logger.error(ex); } }; callback.setFetchingLastAccessed( true ); getLastAccessedTask.execute(courseId); } } }catch(Exception e){ logger.error(e); } }

Target:
public void fetchLastAccessed(final LastAccessManagerCallback callback, final View view, final String courseId){ try{ if(!callback.isFetchingLastAccessed()) { if(courseId!=null && getProfile()!=null && getProfile().username!=null){ String prefName = PrefManager.getPrefNameForLastAccessedBy(getProfile() .username, courseId); final PrefManager prefManager = new PrefManager(MainApplication.instance(), prefName); final String prefModuleId = prefManager.getLastAccessedSubsectionId(); logger.debug("Last Accessed Module ID from Preferences " +prefModuleId); callback.showLastAccessedView(prefModuleId, courseId, null); GetLastAccessedTask getLastAccessedTask = new GetLastAccessedTask(MainApplication.instance()) { @Override public void onFinish(SyncLastAccessedSubsectionResponse result) { syncWithServerOnSuccess(result, prefModuleId, prefManager, courseId, callback, view); } @Override public void onException(Exception ex) { callback.setFetchingLastAccessed( false ); logger.error(ex); } }; callback.setFetchingLastAccessed( true ); getLastAccessedTask.execute(courseId); } } }catch(Exception e){ logger.error(e); } }
Source:
public static byte[] gzip(final byte[] data) { final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); try (final GZIPOutputStream gos = new GZIPOutputStream(byteArrayOutputStream) { { def.setLevel(GZIP_COMPRESSION_LEVEL); } }) { IOUtil.copyStream(new ByteArrayInputStream(data), gos); } catch (final IOException e) { throw new RuntimeException(e); } return byteArrayOutputStream.toByteArray(); }

Target:
public static byte[] gzip(final byte[] data) { final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); try (final GZIPOutputStream gos = new GZIPOutputStream(byteArrayOutputStream) { { def.setLevel(GZIP_COMPRESSION_LEVEL); } }) { IOUtil.copyStream(new ByteArrayInputStream(data), gos); } catch (final IOException e) { throw new RuntimeIOException(e); } return byteArrayOutputStream.toByteArray(); }