auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
protected void setInitialState(ByteBuffer initialState) { if (m_shutdown.get()) { if (exportLog.isDebugEnabled()) { exportLog.debug("Shutdown, ignore initial state proposed on " + m_eds); } return; } try { m_eds.getExecutorService().execute(new Runnable() { @Override public void run() { try { if (exportLog.isDebugEnabled()) { exportLog.debug("Set initial state on host: " + m_hostId); } Integer newLeaderHostId = initialState.getInt(); m_leaderHostId = newLeaderHostId; StringBuilder sb = new StringBuilder("Initialized export coordinator: host ") .append(m_leaderHostId) .append(isPartitionLeader() ? " (localHost) " : " ") .append("is the leader at initial state"); if (isPartitionLeader()) { exportLog.info(sb.toString()); } else if (exportLog.isDebugEnabled()) { exportLog.debug(sb.toString()); } setCoordinatorInitialized(); invokeNext(); } catch (Exception e) { exportLog.error("Failed to change to initial state leader: " + e); } } }); } catch (RejectedExecutionException rej) { if (exportLog.isDebugEnabled()) { exportLog.debug("Initial state rejected by: " + m_eds); } } catch (Exception e) { exportLog.error("Failed to handle initial state: " + e); } }

Target:
protected void setInitialState(ByteBuffer initialState) { if (m_shutdown.get()) { if (exportLog.isDebugEnabled()) { exportLog.debug("Shutdown, ignore initial state proposed on " + m_eds); } return; } try { m_eds.getExecutorService().execute(new Runnable() { @Override public void run() { try { if (exportLog.isDebugEnabled()) { exportLog.debug("Set initial state on host: " + m_hostId); } Integer newLeaderHostId = initialState.getInt(); m_leaderHostId = newLeaderHostId; if (isPartitionLeader()) { exportLog.info(getLeaderMessageAtInitialState()); } else if (exportLog.isDebugEnabled()) { exportLog.debug(getLeaderMessageAtInitialState()); } setCoordinatorInitialized(); invokeNext(); } catch (Exception e) { exportLog.error("Failed to change to initial state leader: " + e); } } }); } catch (RejectedExecutionException rej) { if (exportLog.isDebugEnabled()) { exportLog.debug("Initial state rejected by: " + m_eds); } } catch (Exception e) { exportLog.error("Failed to handle initial state: " + e); } }
Source:
public void writeExternal(ObjectOutput out) throws IOException { URI uri = toURI(); try { System.out.println("writing " + uri.toASCIIString()); out.writeUTF(uri.toASCIIString()); } catch (Exception e) { if (e instanceof IOException) { throw (IOException) e; } throw new IOException(e); } }

Target:
public void writeExternal(ObjectOutput out) throws IOException { URI uri = toURI(); try { out.writeUTF(uri.toASCIIString()); } catch (Exception e) { if (e instanceof IOException) { throw (IOException) e; } throw new IOException(e); } }
Source:
public static void handleViewpointActivation(Session session, Set<Viewpoint> viewpointsToHandle, boolean activateViewpoint, boolean askUserForDependencyActivation) { Collection<Viewpoint> selectedViewpoints = session.getSelectedViewpoints(false); final SortedMap<Viewpoint, Boolean> originalViewpointsMap = Maps.newTreeMap(new ViewpointRegistry.ViewpointComparator()); Collection<Viewpoint> availableViewpoints = ViewpointHelper.getAvailableViewpoints(session); for (final Viewpoint viewpoint : availableViewpoints) { boolean selected = false; for (Viewpoint selectedViewpoint : selectedViewpoints) { if (EqualityHelper.areEquals(selectedViewpoint, viewpoint)) { selected = true; break; } } originalViewpointsMap.put(viewpoint, Boolean.valueOf(selected)); } SortedMap<Viewpoint, Boolean> newViewpointToSelectionStateMap = Maps.newTreeMap(new ViewpointRegistry.ViewpointComparator()); newViewpointToSelectionStateMap.putAll(originalViewpointsMap); ArrayList<Viewpoint> arrayList = new ArrayList<>(); arrayList.addAll(newViewpointToSelectionStateMap.keySet()); for (Viewpoint viewpoint : viewpointsToHandle) { newViewpointToSelectionStateMap.put(viewpoint, activateViewpoint); } Display.getCurrent().syncExec(() -> { ViewpointHelper.applyNewViewpointSelection(originalViewpointsMap, newViewpointToSelectionStateMap, session, true, new ViewpointSelectionCallbackWithConfimationAndDependenciesHandling(askUserForDependencyActivation)); }); }

Target:
public static void handleViewpointActivation(Session session, Set<Viewpoint> viewpointsToHandle, boolean activateViewpoint, boolean askUserForDependencyActivation) { Collection<Viewpoint> selectedViewpoints = session.getSelectedViewpoints(false); final SortedMap<Viewpoint, Boolean> originalViewpointsMap = Maps.newTreeMap(new ViewpointRegistry.ViewpointComparator()); Collection<Viewpoint> availableViewpoints = ViewpointHelper.getAvailableViewpoints(session); for (final Viewpoint viewpoint : availableViewpoints) { boolean selected = false; for (Viewpoint selectedViewpoint : selectedViewpoints) { if (EqualityHelper.areEquals(selectedViewpoint, viewpoint)) { selected = true; break; } } originalViewpointsMap.put(viewpoint, Boolean.valueOf(selected)); } SortedMap<Viewpoint, Boolean> newViewpointToSelectionStateMap = Maps.newTreeMap(new ViewpointRegistry.ViewpointComparator()); newViewpointToSelectionStateMap.putAll(originalViewpointsMap); for (Viewpoint viewpoint : viewpointsToHandle) { newViewpointToSelectionStateMap.put(viewpoint, activateViewpoint); } Display.getCurrent().syncExec(() -> { ViewpointHelper.applyNewViewpointSelection(originalViewpointsMap, newViewpointToSelectionStateMap, session, true, new ViewpointSelectionCallbackWithConfimationAndDependenciesHandling(askUserForDependencyActivation)); }); }
Source:
public TransferDiskImageParameters createInitParams(DiskImage diskImage) { TransferDiskImageParameters parameters = new TransferDiskImageParameters(); parameters.setTransferType(TransferType.Download); parameters.setImageGroupID(diskImage.getId()); String fileExtension = diskImage.getVolumeFormat() == VolumeFormat.COW ? ".qcow2" : ".raw"; parameters.setDownloadFilename(diskImage.getDiskAlias() + fileExtension); parameters.setTransferSize(diskImage.getActualSizeInBytes()); parameters.setTransferringViaBrowser(true); return parameters; }

Target:
public static TransferDiskImageParameters createInitParams(DiskImage diskImage) { TransferDiskImageParameters parameters = new TransferDiskImageParameters(); parameters.setTransferType(TransferType.Download); parameters.setImageGroupID(diskImage.getId()); String fileExtension = diskImage.getVolumeFormat() == VolumeFormat.COW ? ".qcow2" : ".raw"; parameters.setDownloadFilename(diskImage.getDiskAlias() + fileExtension); parameters.setTransferSize(diskImage.getActualSizeInBytes()); parameters.setTransferringViaBrowser(true); return parameters; }
Source:
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { AppLog.i(T.READER, "Upgrading database from version " + oldVersion + " to version " + newVersion + " IN PROGRESS"); int currentVersion = oldVersion; if (currentVersion <= DB_LAST_VERSION_WITHOUT_MIGRATION_SCRIPT) { reset(db); currentVersion = newVersion; } switch (currentVersion) { case 136: currentVersion++; case 137: db.execSQL("ALTER TABLE tbl_posts ADD is_private_atomic BOOLEAN;"); currentVersion++; case 138: ReaderDiscoverCardsTable.INSTANCE.createTable(db); currentVersion++; case 139: db.execSQL("DROP TABLE IF EXISTS tbl_tags_recommended;"); currentVersion++; case 140: db.execSQL("ALTER TABLE tbl_posts ADD tags TEXT;"); currentVersion++; case 141: String[] args = {Integer.toString(ReaderTagType.FOLLOWED.toInt())}; db.execSQL("DELETE FROM tbl_tags WHERE tag_type=?", args); currentVersion++; case 142: db.execSQL("DROP TABLE IF EXISTS tbl_recommended_blogs;"); currentVersion++; case 143: db.execSQL("ALTER TABLE tbl_posts ADD is_wpforteams_site BOOLEAN;"); currentVersion++; case 144: db.execSQL("ALTER TABLE tbl_blog_info ADD is_wp_for_teams BOOLEAN;"); currentVersion++; case 145: db.execSQL("ALTER TABLE tbl_blog_info ADD organization_id INTEGER;"); db.execSQL("ALTER TABLE tbl_posts ADD organization_id INTEGER;"); currentVersion++; } if (currentVersion != newVersion) { throw new RuntimeException( "Migration from version " + oldVersion + " to version " + newVersion + " FAILED. "); } AppLog.i(T.READER, "Upgrading database from version " + oldVersion + " to version " + newVersion + " SUCCEEDED"); }

Target:
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { AppLog.i(T.READER, "Upgrading database from version " + oldVersion + " to version " + newVersion + " IN PROGRESS"); int currentVersion = oldVersion; if (currentVersion <= DB_LAST_VERSION_WITHOUT_MIGRATION_SCRIPT) { reset(db); currentVersion = newVersion; } switch (currentVersion) { case 136: currentVersion++; case 137: db.execSQL("ALTER TABLE tbl_posts ADD is_private_atomic BOOLEAN;"); currentVersion++; case 138: ReaderDiscoverCardsTable.INSTANCE.createTable(db); currentVersion++; case 139: db.execSQL("DROP TABLE IF EXISTS tbl_tags_recommended;"); currentVersion++; case 140: db.execSQL("ALTER TABLE tbl_posts ADD tags TEXT;"); currentVersion++; case 141: String[] args = {Integer.toString(ReaderTagType.FOLLOWED.toInt())}; db.execSQL("DELETE FROM tbl_tags WHERE tag_type=?", args); currentVersion++; case 142: db.execSQL("DROP TABLE IF EXISTS tbl_recommended_blogs;"); currentVersion++; case 143: currentVersion++; case 144: currentVersion++; case 145: db.execSQL("ALTER TABLE tbl_blog_info ADD organization_id INTEGER;"); db.execSQL("ALTER TABLE tbl_posts ADD organization_id INTEGER;"); currentVersion++; } if (currentVersion != newVersion) { throw new RuntimeException( "Migration from version " + oldVersion + " to version " + newVersion + " FAILED. "); } AppLog.i(T.READER, "Upgrading database from version " + oldVersion + " to version " + newVersion + " SUCCEEDED"); }
Source:
public Item[] getDrops() { List<Item> drops = new ArrayList<>(); if (this.lastDamageCause instanceof EntityDamageByEntityEvent) { int EnderPearl = Drops.rand(0, 3); for (int i = 0; i < EnderPearl; i++) { drops.add(Item.get(Item.ENDER_PEARL, 0, 1)); } } return drops.toArray(new Item[drops.size()]); }

Target:
public Item[] getDrops() { List<Item> drops = new ArrayList<>(); if (this.lastDamageCause instanceof EntityDamageByEntityEvent) { int enderPearl = Drops.rand(0, 2); for (int i = 0; i < EnderPearl; i++) { drops.add(Item.get(Item.ENDER_PEARL, 0, 1)); } } return drops.toArray(new Item[drops.size()]); }
Source:
public void addEdge(GenericEdge edge) { Objects.requireNonNull(edge); Objects.requireNonNull(edge.getId()); if (jungGraph.containsEdge(edge)) return; if(!this.getNamespace().equals(edge.getNamespace())){ throw new IllegalArgumentException( String.format("The namespace of the edge (%s) doesn't match the namespace of this graph (%s). Edge: %s ", edge.getNamespace(), this.getNamespace(), edge.toString())); } if (edge.getSource().getNamespace().equalsIgnoreCase(getNamespace()) && getVertex(edge.getSource().getId()) == null) { throw new IllegalArgumentException( String.format("Adding an VertexRef to an unknown Vertex with id=%s in our namespace (%s). Please add the Vertex first to the graph", edge.getSource().getId(), this.getNamespace())); } if (edge.getTarget().getNamespace().equalsIgnoreCase(getNamespace()) && getVertex(edge.getTarget().getId()) == null) { throw new IllegalArgumentException( String.format("Adding an VertexRef to an unknown Vertex with id=%s in our namespace (%s). Please add the Vertex first to the graph", edge.getTarget().getId(), this.getNamespace())); } jungGraph.addEdge(edge, edge.getSource(), edge.getTarget()); edgeToIdMap.put(edge.getId(), edge); }

Target:
public void addEdge(GenericEdge edge) { Objects.requireNonNull(edge); Objects.requireNonNull(edge.getId()); if (jungGraph.containsEdge(edge)) return; if(!this.getNamespace().equals(edge.getNamespace())){ throw new IllegalArgumentException( String.format("The namespace of the edge (%s) doesn't match the namespace of this graph (%s). Edge: %s ", edge.getNamespace(), this.getNamespace(), edge.toString())); } assertVertexFromSameNamespaceIsKnown(edge.getSource()); assertVertexFromSameNamespaceIsKnown(edge.getTarget()); jungGraph.addEdge(edge, edge.getSource(), edge.getTarget()); edgeToIdMap.put(edge.getId(), edge); }
Source:
public int getNumberOfUnitsByType(long type, boolean inTransit, boolean lv) { int num = 0; for (Unit unit : getHangar().getUnits()) { if (!inTransit && !unit.isPresent()) { continue; } if (unit.isMothballed()) { if (type == Unit.ETYPE_MOTHBALLED) { num++; } continue; } Entity en = unit.getEntity(); if (en instanceof GunEmplacement || en instanceof FighterSquadron || en instanceof Jumpship) { continue; } if (type == Entity.ETYPE_MECH && en instanceof Mech) { num++; continue; } if (type == Entity.ETYPE_DROPSHIP && en instanceof Dropship) { num++; continue; } if (type == Entity.ETYPE_SMALL_CRAFT && en instanceof SmallCraft && !(en instanceof Dropship)) { num++; continue; } if (type == Entity.ETYPE_CONV_FIGHTER && en instanceof ConvFighter) { num++; continue; } if (type == Entity.ETYPE_AERO && en instanceof Aero && !(en instanceof SmallCraft || en instanceof ConvFighter)) { num++; continue; } if (type == Entity.ETYPE_INFANTRY && en instanceof Infantry && !(en instanceof BattleArmor)) { num++; continue; } if (type == Entity.ETYPE_BATTLEARMOR && en instanceof BattleArmor) { num++; continue; } if (type == Entity.ETYPE_TANK && en instanceof Tank) { if ((en.getWeight() <= 50 && lv) || (en.getWeight() > 50 && !lv)) { num++; } continue; } if (type == Entity.ETYPE_PROTOMECH && en instanceof Protomech) { num++; } } return num; }

Target:
public int getNumberOfUnitsByType(long type, boolean inTransit, boolean lv) { int num = 0; for (Unit unit : getHangar().getUnits()) { if (!inTransit && !unit.isPresent()) { continue; } if (unit.isMothballed()) { if (type == Unit.ETYPE_MOTHBALLED) { num++; } continue; } Entity en = unit.getEntity(); if ((en instanceof GunEmplacement) || (en instanceof FighterSquadron) || (en instanceof Jumpship)) { continue; } if ((type == Entity.ETYPE_MECH) && (en instanceof Mech)) { num++; continue; } if ((type == Entity.ETYPE_DROPSHIP) && (en instanceof Dropship)) { num++; continue; } if ((type == Entity.ETYPE_SMALL_CRAFT) && (en instanceof SmallCraft) && !(en instanceof Dropship)) { num++; continue; } if ((type == Entity.ETYPE_CONV_FIGHTER) && (en instanceof ConvFighter)) { num++; continue; } if ((type == Entity.ETYPE_AERO) && (en instanceof Aero) && !((en instanceof SmallCraft) || (en instanceof ConvFighter))) { num++; continue; } if ((type == Entity.ETYPE_INFANTRY) && (en instanceof Infantry) && !(en instanceof BattleArmor)) { num++; continue; } if ((type == Entity.ETYPE_BATTLEARMOR) && (en instanceof BattleArmor)) { num++; continue; } if ((type == Entity.ETYPE_TANK) && (en instanceof Tank)) { if (((en.getWeight() <= 50) && lv) || ((en.getWeight() > 50) && !lv)) { num++; } continue; } if ((type == Entity.ETYPE_PROTOMECH) && (en instanceof Protomech)) { num++; } } return num; }
Source:
protected void updateVmPayload() { VmDeviceDAO dao = getVmDeviceDao(); VmPayload payload = getParameters().getVmPayload(); if (payload != null) { List<VmDevice> disks = dao.getVmDeviceByVmIdAndType(getVmId(), VmDeviceType.DISK.getName()); VmDevice oldPayload = null; for (VmDevice disk : disks) { if (VmPayload.isPayload(disk.getSpecParams())) { oldPayload = disk; break; } } if (oldPayload != null) { List<VmDeviceId> devs = new ArrayList<VmDeviceId>(); devs.add(oldPayload.getId()); dao.removeAll(devs); } VmDeviceUtils.addManagedDevice(new VmDeviceId(Guid.NewGuid(), getVmId()), VmDeviceType.DISK, payload.getType(), payload.getSpecParams(), true, true, ""); } }

Target:
protected void updateVmPayload() { VmDeviceDAO dao = getVmDeviceDao(); VmPayload payload = getParameters().getVmPayload(); if (payload != null) { List<VmDevice> disks = dao.getVmDeviceByVmIdAndType(getVmId(), VmDeviceType.DISK.getName()); VmDevice oldPayload = null; for (VmDevice disk : disks) { if (VmPayload.isPayload(disk.getSpecParams())) { oldPayload = disk; break; } } if (oldPayload != null) { List<VmDeviceId> devs = new ArrayList<VmDeviceId>(); devs.add(oldPayload.getId()); dao.removeAll(devs); } VmDeviceUtils.addManagedDevice(new VmDeviceId(Guid.NewGuid(), getVmId()), VmDeviceType.DISK, payload.getType(), payload.getSpecParams(), true, true); } }
Source:
private HBox createNameArea() { HBox nameArea = new HBox(); nameText = new Text(panelName); nameText.setId(model.getDefaultRepo() + "_col" + panelIndex + "_nameText"); nameBox = new HBox(); nameBox.getChildren().add(nameText); nameBox.setMinWidth(330); nameBox.setMaxWidth(330); nameBox.setAlignment(Pos.CENTER_LEFT); nameBox.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) { if (mouseEvent.getClickCount() == 2) { mouseEvent.consume(); activateInplaceRename(); } } } }); renameButton = new Label(RENAME_PANEL); renameButton.getStyleClass().add("label-button"); renameButton.setId(model.getDefaultRepo() + "_col" + panelIndex + "_renameButton"); renameButton.setOnMouseClicked(e -> { e.consume(); activateInplaceRename(); }); HBox renameBox = new HBox(); renameBox.getChildren().add(renameButton); renameBox.setAlignment(Pos.TOP_RIGHT); nameArea.getChildren().addAll(nameBox, renameButton); nameArea.setMinWidth(360); nameArea.setMaxWidth(360); return nameArea; }

Target:
private HBox createNameArea() { HBox nameArea = new HBox(); nameText = new Text(panelName); nameText.setId(model.getDefaultRepo() + "_col" + panelIndex + "_nameText"); nameBox = new HBox(); nameBox.getChildren().add(nameText); nameBox.setMinWidth(330); nameBox.setMaxWidth(330); nameBox.setAlignment(Pos.CENTER_LEFT); nameBox.setOnMouseClicked(mouseEvent -> { if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) { if (mouseEvent.getClickCount() == 2) { mouseEvent.consume(); activateInplaceRename(); } } }); renameButton = new Label(RENAME_PANEL); renameButton.getStyleClass().add("label-button"); renameButton.setId(model.getDefaultRepo() + "_col" + panelIndex + "_renameButton"); renameButton.setOnMouseClicked(e -> { e.consume(); activateInplaceRename(); }); HBox renameBox = new HBox(); renameBox.getChildren().add(renameButton); renameBox.setAlignment(Pos.TOP_RIGHT); nameArea.getChildren().addAll(nameBox, renameButton); nameArea.setMinWidth(360); nameArea.setMaxWidth(360); return nameArea; }
Source:
public void CompletePcapPacketTest() throws IOException, BadPcapFileException, BadPacketException { PcapTestTrace trace = PcapTestTrace.MOSTLY_UDP; assumeTrue(trace.exists()); try (PcapFile file = trace.getTrace();) { file.seekPacket(36); PcapPacket packet = file.parseNextPacket(); if (packet == null) { fail("CompletePcapPacketTest has failed!"); return; } assertEquals(PcapProtocol.PCAP, packet.getProtocol()); assertTrue(packet.hasProtocol(PcapProtocol.PCAP)); assertTrue(packet.hasProtocol(PcapProtocol.UNKNOWN)); assertFalse(packet.hasProtocol(PcapProtocol.TCP)); assertTrue(packet.validate()); assertEquals(86567859, packet.hashCode()); assertFalse(packet.equals(null)); assertFalse(packet.equals(file.parseNextPacket())); assertEquals(EXPECTED_FIELDS, packet.getFields()); assertEquals(EXPECTED_TOSTRING, packet.toString()); assertEquals("Frame 36: 75 bytes on wire, 75 bytes captured", packet.getLocalSummaryString()); assertEquals("Source Port: 2719, Destination Port: 53", packet.getGlobalSummaryString()); assertEquals(new PcapEndpoint(packet, true), packet.getSourceEndpoint()); assertEquals(new PcapEndpoint(packet, false), packet.getDestinationEndpoint()); ByteBuffer payload = packet.getPayload(); if (payload == null) { fail("CompletePcapPacketTest has failed!"); return; } assertEquals(fPayload, payload.flip()); assertEquals(36, packet.getIndex()); assertEquals(75, packet.getOriginalLength()); assertEquals(75, packet.getIncludedLength()); assertEquals(1120469632829277L, packet.getTimestamp()); assertFalse(packet.isTruncated()); } }

Target:
public void CompletePcapPacketTest() throws IOException, BadPcapFileException, BadPacketException { PcapTestTrace trace = PcapTestTrace.MOSTLY_UDP; assumeTrue(trace.exists()); try (PcapFile file = trace.getTrace();) { file.seekPacket(36); PcapPacket packet = file.parseNextPacket(); if (packet == null) { fail("CompletePcapPacketTest has failed!"); return; } assertEquals(PcapProtocol.PCAP, packet.getProtocol()); assertTrue(packet.hasProtocol(PcapProtocol.PCAP)); assertTrue(packet.hasProtocol(PcapProtocol.UNKNOWN)); assertFalse(packet.hasProtocol(PcapProtocol.TCP)); assertTrue(packet.validate()); assertEquals(86567859, packet.hashCode()); assertFalse(packet.equals(null)); assertFalse(packet.equals(file.parseNextPacket())); assertEquals(EXPECTED_FIELDS, packet.getFields()); assertEquals(EXPECTED_TOSTRING, packet.toString()); assertEquals("Frame 36: 75 bytes on wire, 75 bytes captured", packet.getLocalSummaryString()); assertEquals("Source Port: 2719, Destination Port: 53", packet.getGlobalSummaryString()); assertEquals(new PcapEndpoint(packet, true), packet.getSourceEndpoint()); assertEquals(new PcapEndpoint(packet, false), packet.getDestinationEndpoint()); ByteBuffer payload = packet.getPayload(); if (payload == null) { fail("CompletePcapPacketTest has failed!"); return; } assertEquals(36, packet.getIndex()); assertEquals(75, packet.getOriginalLength()); assertEquals(75, packet.getIncludedLength()); assertEquals(1120469632829277L, packet.getTimestamp()); assertFalse(packet.isTruncated()); } }
Source:
public void testGatewayScatterGather() { Message<?> bestQuoteMessage = this.gateway.exchange(new GenericMessage<String>("foo")); Object payload = bestQuoteMessage.getPayload(); assertThat(payload, instanceOf(List.class)); assertThat(((List) payload).size(), greaterThanOrEqualTo(1)); }

Target:
public void testGatewayScatterGather() { Message<?> bestQuoteMessage = this.gateway.exchange(new GenericMessage<String>("foo")); Object payload = bestQuoteMessage.getPayload(); assertThat(payload, instanceOf(List.class)); assertThat(((List<?>) payload).size(), greaterThanOrEqualTo(1)); }
Source:
public ISchedulerClient getSchedulerClient() throws SchedulerException { LOG.fine("Creating scheduler client"); ISchedulerClient schedulerClient; if (Context.schedulerService(config)) { SchedulerStateManagerAdaptor statemgr = Runtime.schedulerStateManagerAdaptor(runtime); Scheduler.SchedulerLocation schedulerLocation = statemgr.getSchedulerLocation(Runtime.topologyName(runtime)); if (schedulerLocation == null) { throw new SchedulerException("Failed to get scheduler location"); } LOG.log(Level.FINE, "Scheduler is listening on location: {0} ", schedulerLocation.toString()); schedulerClient = new HttpServiceSchedulerClient(config, runtime, schedulerLocation.getHttpEndpoint()); } else { final IScheduler scheduler = LauncherUtils.getInstance() .getSchedulerInstance(config, runtime); LOG.fine("Invoke scheduler as a library"); schedulerClient = new LibrarySchedulerClient(config, runtime, scheduler); } return schedulerClient; }

Target:
public ISchedulerClient getSchedulerClient() throws SchedulerException { LOG.fine("Creating scheduler client"); ISchedulerClient schedulerClient; if (Context.schedulerService(config)) { SchedulerStateManagerAdaptor statemgr = Runtime.schedulerStateManagerAdaptor(runtime); Scheduler.SchedulerLocation schedulerLocation = statemgr.getSchedulerLocation(Runtime.topologyName(runtime)); if (schedulerLocation == null) { throw new SchedulerException("Failed to get scheduler location from state manager"); } LOG.log(Level.FINE, "Scheduler is listening on location: {0} ", schedulerLocation.toString()); schedulerClient = new HttpServiceSchedulerClient(config, runtime, schedulerLocation.getHttpEndpoint()); } else { final IScheduler scheduler = LauncherUtils.getInstance() .getSchedulerInstance(config, runtime); LOG.fine("Invoke scheduler as a library"); schedulerClient = new LibrarySchedulerClient(config, runtime, scheduler); } return schedulerClient; }
Source:
protected String formatFileName(String filename, String count) { StringBuilder sb = new StringBuilder(requireNonNull(filename)); int offset = filename.lastIndexOf('.'); if (offset == -1) { offset = filename.length(); } sb.insert(offset, count); return sb.toString(); }

Target:
protected String formatFileName(String filename, String count) { requireNonNull(filename); String extension = FilenameUtils.getExtension(filename); if (!extension.isBlank()) { extension = FilenameUtils.EXTENSION_SEPARATOR_STR + extension; } return String.format("%s%s%s", FilenameUtils.getBaseName(filename), count, extension); }
Source:
private boolean isGenerative(final String methodType) { return methodType.equals("GEN"); }

Target:
private boolean isGenerative(final String methodType) { return methodType.equals(MethodType.GENERATIVE.getCode()); }
Source:
private boolean isAllowedVAADINBuildOrStaticUrl(String filenameWithPath) { return filenameWithPath.startsWith("/" + VAADIN_BUILD_FILES_PATH) || filenameWithPath.startsWith("/" + VAADIN_STATIC_FILES_PATH) || themeFolder.matcher(filenameWithPath).find(); }

Target:
private boolean isAllowedVAADINBuildOrStaticUrl(String filenameWithPath) { return filenameWithPath.startsWith("/" + VAADIN_BUILD_FILES_PATH) || filenameWithPath.startsWith("/" + VAADIN_STATIC_FILES_PATH) || APP_THEME_PATTERN.matcher(filenameWithPath).find(); }
Source:
public FailedLoginCounter() { buckets = new HashMap<Long, Map<String,Integer>>(); userFailedAttempts = new HashMap<String,Integer>(); }

Target:
public FailedLoginCounter() { m_timeBucketQueue = new LinkedList<TimeBucket>(); m_userFailedAttempts = new HashMap<String,Integer>(); m_ipFailedAttempts = new HashMap<String,Integer>(); }
Source:
public static EmptyMessage manageError(OSException e, Response response) { if (e == null) { LOGGER.error(ErrorDescriptions.EXCEPTION_NULL); throw new NullPointerException(ErrorDescriptions.EXCEPTION_NULL); } String errMess = e.getMessage(); if (errMess == null) { LOGGER.error(ErrorDescriptions.ERROR_MESS_NULL); throw new NullPointerException(ErrorDescriptions.ERROR_MESS_NULL); } if(errMess.equals(ErrorDescriptions.DECRYPTION_FAILED)) { LOGGER.info("Sending empty ACK message due to Response decryption failure"); return EmptyMessage.newACK(response); } if (!response.isConfirmable()) { LOGGER.error("An Empty Message will not be created"); return null; } LOGGER.info("Sending empty RST message"); return EmptyMessage.newRST(response); }

Target:
public static EmptyMessage manageError(OSException e, Response response) { if (e == null) { LOGGER.error(ErrorDescriptions.EXCEPTION_NULL); throw new NullPointerException(ErrorDescriptions.EXCEPTION_NULL); } String errMess = e.getMessage(); if (errMess == null) { LOGGER.error(ErrorDescriptions.ERROR_MESS_NULL); throw new NullPointerException(ErrorDescriptions.ERROR_MESS_NULL); } if (!response.isConfirmable()) { LOGGER.error("An Empty Message will not be created"); return null; } LOGGER.info("Sending empty RST message"); return EmptyMessage.newRST(response); }
Source:
private String getBillingFrequencyDescription(Award award) { if (award == null || award.getBillingFrequency() == null) { return StringUtils.EMPTY; } return award.getBillingFrequency().getFrequencyDescription(); }

Target:
private String getBillingFrequencyDescription(Award award) { if (ObjectUtils.isNull(award) || ObjectUtils.isNull(award.getBillingFrequency())) { return StringUtils.EMPTY; } return award.getBillingFrequency().getFrequencyDescription(); }
Source:
protected final void addWaitKey(String name, W key, long timeoutMs) { long deadline = timeoutMs > 0 ? Clock.currentTimeMillis() + timeoutMs : NO_WAIT_KEY_DEADLINE; if (timeoutMs > 0) { waitTimeouts.putIfAbsent(BiTuple.of(name, key.invocationUid), BiTuple.of(timeoutMs, deadline)); } if (timeoutMs != 0) { addLiveOperation(key, deadline); } }

Target:
protected final void addWaitKey(String name, W key, long timeoutMs) { long deadline; if (timeoutMs > 0) { long now = Clock.currentTimeMillis(); deadline = Long.MAX_VALUE - now >= timeoutMs ? now + timeoutMs : Long.MAX_VALUE; waitTimeouts.putIfAbsent(BiTuple.of(name, key.invocationUid), BiTuple.of(timeoutMs, deadline)); } else { deadline = NO_WAIT_KEY_DEADLINE; } if (timeoutMs != 0) { addLiveOperation(key, deadline); } }
Source:
public void testCompare() { Component componentB = new Component("B", "B", "job/A", false, new ArrayList<Pipeline>(), 3, false); Component componentA = new Component("A", "A", "job/B", false, new ArrayList<Pipeline>(), 3, false); List<Component> list = new ArrayList<Component>(); list.add(componentB); list.add(componentA); Collections.sort(list, new NameComparator.DescriptorImpl().createInstance()); assertEquals(componentA, list.get(0)); assertEquals(componentB, list.get(1)); }

Target:
public void testCompare() { Component componentB = new Component("B", "B", "job/A", false, new ArrayList<Pipeline>(), 3, pagingEnabledFalse); Component componentA = new Component("A", "A", "job/B", false, new ArrayList<Pipeline>(), 3, pagingEnabledFalse); List<Component> list = new ArrayList<Component>(); list.add(componentB); list.add(componentA); Collections.sort(list, new NameComparator.DescriptorImpl().createInstance()); assertEquals(componentA, list.get(0)); assertEquals(componentB, list.get(1)); }
Source:
private void checkForPotentialVendorDeletionAttempts(Collection<PaymentWorksVendor> vendors) { boolean vendorDeletionAttemptExists = vendors.stream() .anyMatch((vendor) -> StringUtils.equalsIgnoreCase( PaymentWorksConstants.SUPPLIER_UPLOAD_DELETE_INDICATOR, vendor.getRequestingCompanyLegalNameForProcessing())); if (vendorDeletionAttemptExists) { LOG.error("checkForPotentialVendorDeletionAttempts, discovered a potential attempt to delete a vendor via the supplier upload"); throw new RuntimeException("Detected a potential attempt to delete a vendor via the supplier upload"); } }

Target:
private void checkForPotentialVendorDeletionAttempts(Collection<PaymentWorksVendor> vendors) { List<PaymentWorksVendor> vendorDeletions = vendors.stream() .filter((vendor) -> StringUtils.equalsIgnoreCase( PaymentWorksConstants.SUPPLIER_UPLOAD_DELETE_INDICATOR, vendor.getRequestingCompanyLegalNameForProcessing())) .collect(Collectors.toCollection(ArrayList::new)); if (!vendorDeletions.isEmpty()) { String vendorDeletionNumbers = buildVendorNumberList(vendorDeletions); LOG.error("checkForPotentialVendorDeletionAttempts, discovered a potential attempt to delete these vendors via the supplier upload: " + vendorDeletionNumbers); throw new RuntimeException("Detected a potential attempt to delete the following vendors via the supplier upload: " + vendorDeletionNumbers); } }
Source:
public final void run(Configuration config, final Environment env) throws Exception { env.jersey().register(HttpRemotingJerseyFeature.INSTANCE); env.jersey().register(new TestResource()); env.jersey().register(new EmptyOptionalTo204ExceptionMapper()); env.getObjectMapper().registerModule(new Jdk8Module()); }

Target:
public final void run(Configuration config, final Environment env) throws Exception { env.jersey().register(HttpRemotingJerseyFeature.INSTANCE); env.jersey().register(new JacksonMessageBodyProvider(ObjectMappers.newServerObjectMapper())); env.jersey().register(new EmptyOptionalTo204ExceptionMapper()); env.jersey().register(new TestResource()); }
Source:
public Date convert(String source) { DateFormat df = new SimpleDateFormat(dateFormatString); try { return df.parse(source); } catch (ParseException cause) { throw new RuntimeException(cause); } }

Target:
public Date convert(String source) { return Date.from(Instant.parse(source)); }
Source:
@Test public void port(){ story.addStep(new Statement() { @Override public void evaluate() throws Throwable { assumeDocker(); WorkflowJob p = story.j.jenkins.createProject(WorkflowJob.class, "prj"); p.setDefinition(new CpsFlowDefinition( "node {\n" + " def img = docker.image('httpd:2.4.12')\n" + " def container = img.run('-p 12345:80')\n" + " def port = container.port(80)\n" + " container.stop()\n" + " echo \"container running on ${port}\"" + "}", true)); WorkflowRun r = story.j.assertBuildStatusSuccess(p.scheduleBuild2(0)); story.j.assertLogContains("container running on 0.0.0.0:12345", r); } }); }

Target:
@Test public void port(){ story.addStep(new Statement() { @Override public void evaluate() throws Throwable { assumeDocker(); WorkflowJob p = story.j.jenkins.createProject(WorkflowJob.class, "prj"); p.setDefinition(new CpsFlowDefinition( "node {\n" + " def img = docker.image('httpd:2.4.12')\n" + " def port = img.withRun('-p 12345:80') { c -> c.port(80) }\n" + " echo \"container running on ${port}\"" + "}", true)); WorkflowRun r = story.j.assertBuildStatusSuccess(p.scheduleBuild2(0)); story.j.assertLogContains("container running on 0.0.0.0:12345", r); } }); }
Source:
public int getMaxIntermediateSize() { return Longs.BYTES + Floats.BYTES; }

Target:
public int getMaxIntermediateSize() { return Long.BYTES + Float.BYTES; }
Source:
public Integer getWarningLowSpaceSize() { return getWarningLowSpaceIndicator() == null ? 0 : getTotalDiskSize() * getWarningLowSpaceIndicator() / 100; }

Target:
public int getWarningLowSpaceSize() { return getWarningLowSpaceIndicator() == null ? 0 : getTotalDiskSize() * getWarningLowSpaceIndicator() / 100; }
Source:
public void close() throws Exception{ if (!running) { return; } running = false; LOG.info("Closing {}", this); client.getUnhandledErrorListenable().removeListener(this); client.getConnectionStateListenable().removeListener(listener); Exception exception = null; try { cache.close(); } catch (Exception e) { exception = ExceptionUtils.firstOrSuppressed(e, exception); } try { leaderLatch.close(); } catch (Exception e) { exception = ExceptionUtils.firstOrSuppressed(e, exception); } if (exception != null) { throw new Exception("Could not properly stop the ZooKeeperLeaderElectionDriver.", exception); } }

Target:
public void close() throws Exception{ if (!running) { return; } running = false; LOG.info("Closing {}", this); client.getUnhandledErrorListenable().removeListener(this); client.getConnectionStateListenable().removeListener(listener); Exception exception = null; try { cache.close(); } catch (Exception e) { exception = e; } try { leaderLatch.close(); } catch (Exception e) { exception = ExceptionUtils.firstOrSuppressed(e, exception); } if (exception != null) { throw new Exception("Could not properly stop the ZooKeeperLeaderElectionDriver.", exception); } }
Source:
public MainModule(Context context) { this.context = context.getApplicationContext(); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.setPrettyPrinting(); gsonBuilder.disableHtmlEscaping(); gsonBuilder.registerTypeAdapter(ApiItem.class, new CollectionDeserializer()); gsonBuilder.registerTypeAdapter(Content.class, new PageContentDeserializer()); gsonBuilder.registerTypeAdapter(CanvassData.class, new CanvassDataSerializer()); gson = gsonBuilder.create(); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); rxPrefs = RxSharedPreferences.create(preferences); config = new ConfigImpl(context); }

Target:
public MainModule(Context context) { this.context = context.getApplicationContext(); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.disableHtmlEscaping(); gsonBuilder.registerTypeAdapter(ApiItem.class, new CollectionDeserializer()); gsonBuilder.registerTypeAdapter(Content.class, new PageContentDeserializer()); gsonBuilder.registerTypeAdapter(CanvassData.class, new CanvassDataSerializer()); gson = gsonBuilder.create(); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); rxPrefs = RxSharedPreferences.create(preferences); config = new ConfigImpl(context); }
Source:
public synchronized void addChild(@NonNull TimeGraphEntry child) { if (fComparator == null) { addChild(fChildren.size(), child); } else { int i = Collections.binarySearch(fChildren, child, fComparator); i = i >= 0 ? i + 1 : -i - 1; addChild(i, child); } }

Target:
public synchronized void addChild(@NonNull TimeGraphEntry child) { if (fComparator == null) { addChild(fChildren.size(), child); } else { int i = Collections.binarySearch(fChildren, child, fComparator); if (i >= 0) { while (i < fChildren.size() && fComparator.compare(child, fChildren.get(i)) == 0) { i++; } } else { i = -i - 1; } addChild(i, child); } }
Source:
private static ShapelessOreRecipe shapelessFactory( JsonContext context, JsonObject json ) { String group = JsonUtils.getString( json, "group", AppEng.MOD_ID + ":part_shapeless_crafting" ); NonNullList<Ingredient> ings = NonNullList.create(); for( JsonElement ele : JsonUtils.getJsonArray( json, "ingredients" ) ) { ings.add( CraftingHelper.getIngredient( ele, context ) ); } if( ings.isEmpty() ) { throw new JsonParseException( "No ingredients for shapeless recipe" ); } JsonObject resultObject = (JsonObject) json.get( "result" ); int count = JsonUtils.getInt( resultObject, "count", 1 ); String ingredient = resultObject.get( "part" ).getAsString(); Object result = (Object) Api.INSTANCE.registries().recipes().resolveItem( AppEng.MOD_ID, ingredient ); if( result instanceof ResolverResult ) { ResolverResult resolverResult = (ResolverResult) result; Item item = Item.getByNameOrId( AppEng.MOD_ID + ":" + resolverResult.itemName ); if( item == null ) { AELog.warn( "item was null for " + resolverResult.itemName + " ( " + ingredient + " )!" ); throw new JsonSyntaxException( "Got a null item for " + resolverResult.itemName + " ( " + ingredient + " ). This should never happen!" ); } ItemStack itemStack = new ItemStack( item, count, resolverResult.damageValue, resolverResult.compound ); return new ShapelessOreRecipe( new ResourceLocation( group ), ings, itemStack ); } throw new JsonSyntaxException( "Couldn't find the resulting item in AE. This means AE was provided a recipe that it shouldn't be handling.\n" + "Was looking for : '" + ingredient + "'." ); }

Target:
private static ShapelessOreRecipe shapelessFactory( JsonContext context, JsonObject json ) { String group = JsonUtils.getString( json, "group", "" ); NonNullList<Ingredient> ings = NonNullList.create(); for( JsonElement ele : JsonUtils.getJsonArray( json, "ingredients" ) ) { ings.add( CraftingHelper.getIngredient( ele, context ) ); } if( ings.isEmpty() ) { throw new JsonParseException( "No ingredients for shapeless recipe" ); } JsonObject resultObject = (JsonObject) json.get( "result" ); int count = JsonUtils.getInt( resultObject, "count", 1 ); String ingredient = resultObject.get( "part" ).getAsString(); Object result = (Object) Api.INSTANCE.registries().recipes().resolveItem( AppEng.MOD_ID, ingredient ); if( result instanceof ResolverResult ) { ResolverResult resolverResult = (ResolverResult) result; Item item = Item.getByNameOrId( AppEng.MOD_ID + ":" + resolverResult.itemName ); if( item == null ) { AELog.warn( "item was null for " + resolverResult.itemName + " ( " + ingredient + " )!" ); throw new JsonSyntaxException( "Got a null item for " + resolverResult.itemName + " ( " + ingredient + " ). This should never happen!" ); } ItemStack itemStack = new ItemStack( item, count, resolverResult.damageValue, resolverResult.compound ); return new ShapelessOreRecipe( group.isEmpty() ? null : new ResourceLocation( group ), ings, itemStack ); } throw new JsonSyntaxException( "Couldn't find the resulting item in AE. This means AE was provided a recipe that it shouldn't be handling.\n" + "Was looking for : '" + ingredient + "'." ); }
Source:
public CommandResult execute(CommandInvocation commandInvocation) throws IOException { if (help) { commandInvocation.getShell().out().print(commandInvocation.getHelpInfo("touch")); return CommandResult.SUCCESS; } if (arguments == null || arguments.size() < 1) { commandInvocation.getShell().out().print("touch: Invalid arguments"); return CommandResult.FAILURE; } try { for (File file : arguments) { file.createNewFile(); } } catch (IOException ioe) { commandInvocation.getShell().out().print("touch: " + ioe.getMessage()); return CommandResult.FAILURE; } return CommandResult.SUCCESS; }

Target:
public CommandResult execute(CommandInvocation commandInvocation) throws IOException { if (help) { commandInvocation.getShell().out().print(commandInvocation.getHelpInfo("touch")); return CommandResult.SUCCESS; } if (arguments == null || arguments.size() < 1) { commandInvocation.getShell().out().print("touch: Invalid arguments"); return CommandResult.FAILURE; } try { for (File file : arguments) { if (file.exists()) { continue; } file.createNewFile(); } } catch (IOException ioe) { commandInvocation.getShell().out().print("touch: " + ioe.getMessage()); return CommandResult.FAILURE; } return CommandResult.SUCCESS; }
Source:
public static Champ fromCbor(Cborable cbor) { if (! (cbor instanceof CborObject.CborList)) throw new IllegalStateException("Invalid cbor for CHAMP! " + cbor); List<? extends Cborable> list = ((CborObject.CborList) cbor).value; BitSet dataMap = BitSet.valueOf(((CborObject.CborByteArray)list.get(0)).value); BitSet nodeMap = BitSet.valueOf(((CborObject.CborByteArray)list.get(1)).value); List<? extends Cborable> contentsCbor = ((CborObject.CborList) list.get(2)).value; List<HashPrefixPayload> contents = new ArrayList<>(); for (int i=0; i < contentsCbor.size(); i++) { Cborable keyOrHash = contentsCbor.get(i); if (keyOrHash instanceof CborObject.CborList) { List<KeyElement> mappings = new ArrayList<>(); List<? extends Cborable> mappingsCbor = ((CborObject.CborList) keyOrHash).value; for (int j=0; j < mappingsCbor.size(); j += 2) { byte[] key = ((CborObject.CborByteArray) mappingsCbor.get(j)).value; Cborable value = mappingsCbor.get(j + 1); mappings.add(new KeyElement(new ByteArrayWrapper(key), value instanceof CborObject.CborNull ? MaybeMultihash.empty() : MaybeMultihash.of(((CborObject.CborMerkleLink) value).target))); } contents.add(new HashPrefixPayload(mappings.toArray(new KeyElement[0]), null)); } else { contents.add(new HashPrefixPayload(null, MaybeMultihash.of(((CborObject.CborMerkleLink)keyOrHash).target))); } } return new Champ(dataMap, nodeMap, contents.toArray(new HashPrefixPayload[contents.size()])); }

Target:
public static Champ fromCbor(Cborable cbor) { if (! (cbor instanceof CborObject.CborList)) throw new IllegalStateException("Invalid cbor for CHAMP! " + cbor); List<? extends Cborable> list = ((CborObject.CborList) cbor).value; BitSet dataMap = BitSet.valueOf(((CborObject.CborByteArray)list.get(0)).value); BitSet nodeMap = BitSet.valueOf(((CborObject.CborByteArray)list.get(1)).value); List<? extends Cborable> contentsCbor = ((CborObject.CborList) list.get(2)).value; List<HashPrefixPayload> contents = new ArrayList<>(); for (int i=0; i < contentsCbor.size(); i++) { Cborable keyOrHash = contentsCbor.get(i); if (keyOrHash instanceof CborObject.CborList) { List<KeyElement> mappings = new ArrayList<>(); List<? extends Cborable> mappingsCbor = ((CborObject.CborList) keyOrHash).value; for (int j=0; j < mappingsCbor.size(); j += 2) { byte[] key = ((CborObject.CborByteArray) mappingsCbor.get(j)).value; Cborable value = mappingsCbor.get(j + 1); mappings.add(new KeyElement(new ByteArrayWrapper(key), value instanceof CborObject.CborNull ? MaybeMultihash.empty() : MaybeMultihash.of(((CborObject.CborMerkleLink) value).target))); } contents.add(new HashPrefixPayload(mappings.toArray(new KeyElement[0]))); } else { contents.add(new HashPrefixPayload(MaybeMultihash.of(((CborObject.CborMerkleLink)keyOrHash).target))); } } return new Champ(dataMap, nodeMap, contents.toArray(new HashPrefixPayload[contents.size()])); }
Source:
public Addresses loadAddresses() { List<String> configuredAddresses = networkConfig.getAddresses(); if (configuredAddresses.isEmpty()) { configuredAddresses.add("127.0.0.1"); } Addresses addresses = new Addresses(); for (String address : configuredAddresses) { List<Address> addressesForMember = AddressHelper.getSocketAddresses(address); if (!addressesForMember.isEmpty()) { addresses.primary().add(addressesForMember.remove(0)); addresses.secondary().addAll(addressesForMember); } } return addresses; }

Target:
public Addresses loadAddresses() { List<String> configuredAddresses = networkConfig.getAddresses(); if (configuredAddresses.isEmpty()) { configuredAddresses.add("127.0.0.1"); } Addresses addresses = new Addresses(); for (String address : configuredAddresses) { addresses.addAll(AddressHelper.getSocketAddresses(address)); } return addresses; }
Source:
public void testBuilderDefaults() { CoordinatorDynamicConfig defaultConfig = CoordinatorDynamicConfig.builder().build(); assertConfig(defaultConfig, 900000, 524288000, 100, 5, 15, 10, 1, false, ImmutableSet.of(), false, 0, ImmutableSet.of(), 7); }

Target:
public void testBuilderDefaults() { CoordinatorDynamicConfig defaultConfig = CoordinatorDynamicConfig.builder().build(); ImmutableSet<String> emptyList = ImmutableSet.of(); assertConfig(defaultConfig, 900000, 524288000, 100, 5, 15, 10, 1, false, emptyList, false, 0, emptyList, 7); }
Source:
private AzureBlobStorageBuilder buildImpl() { Objects.requireNonNull(endpoint); Objects.requireNonNull(containerName); Objects.requireNonNull(blobName); final List<HttpPipelinePolicy> policies = new ArrayList<>(); if (configuration == null) { configuration = Configuration.NONE; } policies.add(new UserAgentPolicy(BlobConfiguration.NAME, BlobConfiguration.VERSION, configuration)); policies.add(new RequestIdPolicy()); policies.add(new AddDatePolicy()); if (sharedKeyCredential != null) { policies.add(new SharedKeyCredentialPolicy(sharedKeyCredential)); } else if (tokenCredential != null) { policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, String.format("%s://%s/.default", endpoint.getProtocol(), endpoint.getHost()))); } else if (sasTokenCredential != null) { policies.add(new SASTokenCredentialPolicy(sasTokenCredential)); } else { policies.add(new AnonymousCredentialPolicy()); } policies.add(retryPolicy); policies.addAll(this.policies); policies.add(new HttpLoggingPolicy(logLevel)); HttpPipeline pipeline = HttpPipeline.builder() .policies(policies.toArray(new HttpPipelinePolicy[0])) .httpClient(httpClient) .build(); return new AzureBlobStorageBuilder() .url(String.format("%s/%s/%s", endpoint.toString(), containerName, blobName)) .pipeline(pipeline); }

Target:
private AzureBlobStorageBuilder buildImpl() { Objects.requireNonNull(endpoint); Objects.requireNonNull(containerName); Objects.requireNonNull(blobName); final List<HttpPipelinePolicy> policies = new ArrayList<>(); if (configuration == null) { configuration = ConfigurationManager.getConfiguration(); } policies.add(new UserAgentPolicy(BlobConfiguration.NAME, BlobConfiguration.VERSION, configuration)); policies.add(new RequestIdPolicy()); policies.add(new AddDatePolicy()); if (sharedKeyCredential != null) { policies.add(new SharedKeyCredentialPolicy(sharedKeyCredential)); } else if (tokenCredential != null) { policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, String.format("%s/.default", endpoint))); } else if (sasTokenCredential != null) { policies.add(new SASTokenCredentialPolicy(sasTokenCredential)); } else { policies.add(new AnonymousCredentialPolicy()); } policies.add(new RequestRetryPolicy(retryOptions)); policies.addAll(this.policies); policies.add(new HttpLoggingPolicy(logLevel)); HttpPipeline pipeline = HttpPipeline.builder() .policies(policies.toArray(new HttpPipelinePolicy[0])) .httpClient(httpClient) .build(); return new AzureBlobStorageBuilder() .url(String.format("%s/%s/%s", endpoint, containerName, blobName)) .pipeline(pipeline); }
Source:
protected void askForPermission(String[] permissions, int requestCode) { if (getActivity() != null) { if (PermissionsUtil.checkPermissions(permissions[0], getActivity())) { if (permissionListener != null) { permissionListener.onPermissionGranted(permissions, requestCode); } } else { PermissionsUtil.requestPermissions(requestCode, permissions, BaseFragment.this); } } }

Target:
protected void askForPermission(String[] permissions, int requestCode) { if (getActivity() != null) { if (permissionListener != null && getGrantedPermissionsCount(permissions) == permissions.length) { permissionListener.onPermissionGranted(permissions, requestCode); } else { PermissionsUtil.requestPermissions(requestCode, permissions, BaseFragment.this); } } }