input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#vulnerable code public static String toString(final InputStream stream) { StringBuilder out = new StringBuilder(); try { final char[] buffer = new char[0x10000]; Reader in = new InputStreamReader(stream, "UTF-8"); int read; do ...
#fixed code public static String toString(final InputStream stream) { StringBuilder out = new StringBuilder(); try { final char[] buffer = new char[0x10000]; Reader in = new InputStreamReader(stream, StandardCharsets.UTF_8); int read; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean isReturnTypeVoid() { return getReturnType().isType(Void.TYPE); } #location 4 #vulnerability type NULL_DEREFERENCE
#fixed code @Override public boolean isReturnTypeVoid() { return getReturnType() == null || getReturnType().isType(Void.TYPE); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder cb) { Specifications<T> combinedSpecs = null; for (Specification<T> spec : innerSpecs) { if (combinedSpecs == null) { combinedSpe...
#fixed code @Override public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder cb) { Specification<T> combinedSpecs = null; for (Specification<T> spec : innerSpecs) { if (combinedSpecs == null) { combinedSpecs = Sp...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Bean(name = KAFKA_BEAN_NAME, destroyMethod = "stop") @DependsOn("zookeeper") public GenericContainer kafka( KafkaStatusCheck kafkaStatusCheck, KafkaConfigurationProperties kafkaProperties, @Value("${embedded.zookeeper.contain...
#fixed code @Bean(name = KAFKA_BEAN_NAME, destroyMethod = "stop") @DependsOn("zookeeper") public GenericContainer kafka( KafkaStatusCheck kafkaStatusCheck, KafkaConfigurationProperties kafkaProperties, @Value("${embedded.zookeeper.containerZook...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Bean(name = BEAN_NAME_EMBEDDED_SELENIUM, destroyMethod = "stop") @ConditionalOnMissingBean public BrowserWebDriverContainer selenium( ConfigurableEnvironment environment, SeleniumProperties properties, MutableCapabilities cap...
#fixed code @Bean(name = BEAN_NAME_EMBEDDED_SELENIUM, destroyMethod = "stop") @ConditionalOnMissingBean public BrowserWebDriverContainer selenium( ConfigurableEnvironment environment, SeleniumProperties properties, MutableCapabilities capabilit...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("unchecked") protected void createBean(AbstractClassBean<?> bean, Set<AbstractBean<?, ?>> beans) { beans.add(bean); manager.getResolver().addInjectionPoints(bean.getInjectionPoints()); for (AnnotatedMethod<Object> producerMethod ...
#fixed code @SuppressWarnings("unchecked") protected void createBean(AbstractClassBean<?> bean, Set<AbstractBean<?, ?>> beans) { beans.add(bean); manager.getResolver().addInjectionPoints(bean.getInjectionPoints()); for (AnnotatedMethod<Object> producerMethod : bean...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void beginRequest(HttpServletRequest request) { ManagerImpl manager = (ManagerImpl) JNDI.lookup("manager"); SessionContext sessionContext = (SessionContext) manager.getContext(SessionScoped.class); BeanMap sessionBeans = (BeanMap) request....
#fixed code public static void beginRequest(HttpServletRequest request) { }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public String toString() { if (toString != null) { return toString; } toString = "Annotated parameter " + Names.type2String(getDelegate().getClass()); return toString; } #location 8 ...
#fixed code @Override public String toString() { if (toString != null) { return toString; } toString = toDetailedString(); return toString; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public String toString() { StringBuilder buffer = new StringBuilder(); buffer.append(Strings.collectionToString("Enabled deployment types: ", getEnabledDeploymentTypes())); buffer.append(eventManager.toString() + "\n"); buffer.appe...
#fixed code @Override public String toString() { StringBuilder buffer = new StringBuilder(); buffer.append("Manager\n"); buffer.append("Enabled deployment types: " + getEnabledDeploymentTypes() + "\n"); buffer.append("Registered contexts: " + contextMap.keySet()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public final boolean isWebElementSufficientlyShown(WebElement webElement){ final WebView webView = viewFetcher.getFreshestView(viewFetcher.getCurrentViews(WebView.class)); final int[] xyWebView = new int[2]; if(webElement != null){ webView.getLocationOnScreen(xyW...
#fixed code public final boolean isWebElementSufficientlyShown(WebElement webElement){ final WebView webView = viewFetcher.getFreshestView(viewFetcher.getCurrentViews(WebView.class)); final int[] xyWebView = new int[2]; if(webView != null && webElement != null){ webView.getLocatio...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private View getViewOnListLine(AbsListView absListView, int lineIndex){ final long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout(); View view = absListView.getChildAt(lineIndex); while(view == null){ final boolean timedOut = SystemClock.uptimeMil...
#fixed code private View getViewOnListLine(AbsListView absListView, int lineIndex){ final long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout(); View view = absListView.getChildAt(lineIndex); while(view == null){ final boolean timedOut = SystemClock.uptimeMillis() ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private boolean scrollScrollView(int direction, ArrayList<ScrollView> scrollViews){ ScrollView scroll = viewFetcher.getView(ScrollView.class, scrollViews, 0); int height = scroll.getHeight(); height--; int scrollTo = 0; if (direction == DOWN) { scrollTo = (he...
#fixed code private boolean scrollScrollView(int direction, ArrayList<ScrollView> scrollViews){ ScrollView scroll = viewFetcher.getView(ScrollView.class, scrollViews, 0); if(scroll !=null){ int height = scroll.getHeight(); height--; int scrollTo = 0; if (direction == DOWN) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Bitmap getBitmapOfView(final View view){ view.destroyDrawingCache(); view.buildDrawingCache(false); Bitmap orig = view.getDrawingCache(); Bitmap.Config config = null; if(orig != null) { config = orig.getConfig(); } if(config == null) { config ...
#fixed code private Bitmap getBitmapOfView(final View view){ view.destroyDrawingCache(); view.buildDrawingCache(false); Bitmap orig = view.getDrawingCache(); Bitmap.Config config = null; if(orig == null) { return null; } config = orig.getConfig(); if(config == null) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private View getViewOnRecyclerItemIndex(ViewGroup recyclerView, int recyclerViewIndex, int itemIndex){ final long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout(); View view = recyclerView.getChildAt(itemIndex); while(view == null){ final boolea...
#fixed code private View getViewOnRecyclerItemIndex(ViewGroup recyclerView, int recyclerViewIndex, int itemIndex){ final long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout(); View view = recyclerView.getChildAt(itemIndex); while(view == null){ final boolean timedO...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public ArrayList<TextView> clickInRecyclerView(int itemIndex, int recyclerViewIndex, boolean longClick, int time) { View viewOnLine = null; final long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout(); if(itemIndex < 0) itemIndex = 0; ArrayList<...
#fixed code public ArrayList<TextView> clickInRecyclerView(int itemIndex, int recyclerViewIndex, boolean longClick, int time) { View viewOnLine = null; final long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout(); if(itemIndex < 0) itemIndex = 0; ArrayList<View> ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void finishOpenedActivities(){ ArrayList<Activity> activitiesOpened = getAllOpenedActivities(); // Finish all opened activities for (int i = activitiesOpened.size()-1; i >= 0; i--) { sleeper.sleep(MINISLEEP); finishActivity(activitiesOpened.get(i)); } ...
#fixed code public void finishOpenedActivities(){ // Stops the activityStack listener activitySyncTimer.cancel(); ArrayList<Activity> activitiesOpened = getAllOpenedActivities(); // Finish all opened activities for (int i = activitiesOpened.size()-1; i >= 0; i--) { sleeper.slee...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void colorize(InputFile i) { final File f = i.file(); LOGGER.info("Color the file: " + f.getPath()); highlighting.onFile(i); try { final BufferedReader br = new BufferedReader( new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8)); ...
#fixed code public void colorize(InputFile i) { final File f = i.file(); LOGGER.info("Color the file: " + f.getPath()); highlighting.onFile(i); try (final BufferedReader br = new BufferedReader( new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8))) { String...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testExecution() { final CoverageSensor sensor = new CoverageSensor(); try { BufferedReader reader = new BufferedReader( new FileReader(new File(CoverageSensor.class.getResource("/coverage/util/util.go").getFile()))); String sCur...
#fixed code @Test public void testExecution() { final CoverageSensor sensor = new CoverageSensor(); initFile(); sensor.execute(testerContext); Map<String, Map<Integer, Integer>> map = new HashMap<>(); map.put("myProjectKey:mathutil/mathutil.go", ImmutableMap.of(7, 1)); map.put...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static void init() { try { prop.load(new FileInputStream(new File(PATH_FILE))); } catch (FileNotFoundException e) { LOGGER.error("Unable to load the config file", e); } catch (IOException e) { LOGGER.error("Unable to load the config file", e); } }...
#fixed code private static void init() { try { LOGGER.info("Load "+PATH_FILE); InputStream input=GoKeyRule.class.getResourceAsStream(PATH_FILE); if(input==null){ throw new FileNotFoundException(PATH_FILE); } prop.load(input); } catch (IOException e)...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private CharBuffer getFileAsBufferFromPath(Path p) throws IOException { FileInputStream input = new FileInputStream(p.toString()); FileChannel channel = input.getChannel(); ByteBuffer bbuf = channel.map(FileChannel.MapMode.READ_ONLY, 0, (int) channel.size()); return...
#fixed code private CharBuffer getFileAsBufferFromPath(Path p) { try (FileInputStream input = new FileInputStream(p.toString())) { FileChannel channel = input.getChannel(); ByteBuffer bbuf = channel.map(FileChannel.MapMode.READ_ONLY, 0, (int) channel.size()); return Chars...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public RulesProfile createProfile(ValidationMessages validation) { LOGGER.info("Golint Quality profile"); RulesProfile profile = RulesProfile.create("Golint Rules", GoLanguage.KEY); profile.setDefaultProfile(Boolean.TRUE); Properties prop=new Prope...
#fixed code @Override public RulesProfile createProfile(ValidationMessages validation) { LOGGER.info("Golint Quality profile"); RulesProfile profile = RulesProfile.create("Golint Rules", GoLanguage.KEY); profile.setDefaultProfile(Boolean.TRUE); Properties prop=new Properties(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void check(GitlabMergeRequest gitlabMergeRequest) { if (_iid == null) { _iid = gitlabMergeRequest.getIid(); } if (_targetBranch == null) { _targetBranch = gitlabMergeRequest.getTargetBranch(); } if...
#fixed code public void check(GitlabMergeRequest gitlabMergeRequest) { if (_mergeRequestStatus == null) { _mergeRequestStatus = new GitlabMergeRequestStatus(); } if (_iid == null) { _iid = gitlabMergeRequest.getIid(); } i...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void check(GitlabMergeRequest gitlabMergeRequest) { if (mergeRequestStatus == null) { mergeRequestStatus = new GitlabMergeRequestStatus(); } if (iid == null) { iid = gitlabMergeRequest.getIid(); } ...
#fixed code public void check(GitlabMergeRequest gitlabMergeRequest) { if (mergeRequestStatus == null) { mergeRequestStatus = new GitlabMergeRequestStatus(); } if (iid == null) { iid = gitlabMergeRequest.getIid(); } if (t...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static Field getField(final Class<?> clazz, final String fieldName) throws Exception { Field field = clazz.getDeclaredField(fieldName); if (field == null && clazz.getSuperclass() != null) { field = getField(clazz.getSuperclass(), fieldName); } field.setAc...
#fixed code public static Field getField(final Class<?> clazz, final String fieldName) throws Exception { Field field = clazz.getDeclaredField(fieldName); if (field != null) field.setAccessible(true); else if (clazz.getSuperclass() != null) field = getField(clazz.getSuperclass()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testShortArray_AsShorts() throws Exception { assertArrayEquals(new byte[]{1, 2, 3, 4}, binStart().Short((short)0x0102, (short)0x0304).end().toByteArray()); } #location 3 #vulnerability typ...
#fixed code @Test public void testShortArray_AsShorts() throws Exception { assertArrayEquals(new byte[]{1, 2, 3, 4}, BeginBin().Short((short)0x0102, (short)0x0304).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testBitArrayAsBytes() throws Exception { assertArrayEquals(new byte[]{(byte) 0xE3}, binStart().Bit(new byte[]{(byte) 1, (byte) 3, (byte) 0, (byte) 2, (byte) 4, (byte) 1, (byte) 3, (byte) 7}).end().toByteArray()); assertArrayEquals(new byte[]{(b...
#fixed code @Test public void testBitArrayAsBytes() throws Exception { assertArrayEquals(new byte[]{(byte) 0xE3}, BeginBin().Bit(new byte[]{(byte) 1, (byte) 3, (byte) 0, (byte) 2, (byte) 4, (byte) 1, (byte) 3, (byte) 7}).End().toByteArray()); assertArrayEquals(new byte[]{(byte) 0...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public int read() throws IOException { final int result; if (this.bitsInBuffer == 0) { result = this.readByteFromStream(); if (result < 0) { return result; } return result; } else { return this.readBits(JBB...
#fixed code @Override public int read() throws IOException { final int result; if (this.bitsInBuffer == 0) { result = this.readByteFromStream(); if (result >= 0) { this.byteCounter++; } return result; } else { return this.readBits(JBB...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testByteArrayAsByteArray() throws Exception { assertArrayEquals(new byte[]{1, 3, 0, 2, 4, 1, 3, 7}, binStart().Byte(new byte[]{1, 3, 0, 2, 4, 1, 3, 7}).end().toByteArray()); } #location 3 ...
#fixed code @Test public void testByteArrayAsByteArray() throws Exception { assertArrayEquals(new byte[]{1, 3, 0, 2, 4, 1, 3, 7}, BeginBin().Byte(new byte[]{1, 3, 0, 2, 4, 1, 3, 7}).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testBit_MSB0() throws Exception { assertArrayEquals(new byte[]{(byte) 0x80}, binStart(JBBPByteOrder.BIG_ENDIAN, JBBPBitOrder.MSB0).Bit(1).end().toByteArray()); } #location 3 #vulnerability...
#fixed code @Test public void testBit_MSB0() throws Exception { assertArrayEquals(new byte[]{(byte) 0x80}, BeginBin(JBBPByteOrder.BIG_ENDIAN, JBBPBitOrder.MSB0).Bit(1).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testByte() throws Exception { assertArrayEquals(new byte[]{-34}, binStart().Byte(-34).end().toByteArray()); } #location 3 #vulnerability type RESOURCE_LEAK
#fixed code @Test public void testByte() throws Exception { assertArrayEquals(new byte[]{-34}, BeginBin().Byte(-34).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testBitArrayAsInts() throws Exception { assertArrayEquals(new byte[]{(byte) 0xE3}, binStart().Bit(1, 3, 0, 2, 4, 1, 3, 7).end().toByteArray()); assertArrayEquals(new byte[]{(byte) 0x0B}, binStart().Bit(1, 3, 0, 7).end().toByteArray()); } ...
#fixed code @Test public void testBitArrayAsInts() throws Exception { assertArrayEquals(new byte[]{(byte) 0xE3}, BeginBin().Bit(1, 3, 0, 2, 4, 1, 3, 7).End().toByteArray()); assertArrayEquals(new byte[]{(byte) 0x0B}, BeginBin().Bit(1, 3, 0, 7).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testFlush() throws Exception { final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); final JBBPOut out = binStart(buffer); out.Bit(true); assertEquals(0, buffer.size()); out.Flush(); assertEquals(1, buffer.size()); ...
#fixed code @Test public void testFlush() throws Exception { final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); final JBBPOut out = BeginBin(buffer); out.Bit(true); assertEquals(0, buffer.size()); out.Flush(); assertEquals(1, buffer.size()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testLong_LittleEndian() throws Exception { assertArrayEquals(new byte[]{0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01}, binStart().ByteOrder(JBBPByteOrder.LITTLE_ENDIAN).Long(0x0102030405060708L).end().toByteArray()); } ...
#fixed code @Test public void testLong_LittleEndian() throws Exception { assertArrayEquals(new byte[]{0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01}, BeginBin().ByteOrder(JBBPByteOrder.LITTLE_ENDIAN).Long(0x0102030405060708L).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public int readBits(final JBBPBitNumber numOfBitsToRead) throws IOException { int result; final int numOfBitsAsNumber = numOfBitsToRead.getBitNumber(); if (this.bitsInBuffer == 0 && numOfBitsAsNumber == 8) { result = this.readByteFromStream(); re...
#fixed code public int readBits(final JBBPBitNumber numOfBitsToRead) throws IOException { int result; final int numOfBitsAsNumber = numOfBitsToRead.getBitNumber(); if (this.bitsInBuffer == 0 && numOfBitsAsNumber == 8) { result = this.readByteFromStream(); this.byt...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testComplexWriting_1() throws Exception { final ByteArrayOutputStream buffer = new ByteArrayOutputStream(16384); final JBBPOut begin = new JBBPOut(buffer); begin. Bit(1, 2, 3, 0). Bit(true, false, true). ...
#fixed code @Test public void testComplexWriting_1() throws Exception { final byte [] array = BeginBin(). Bit(1, 2, 3, 0). Bit(true, false, true). Align(). Byte(5). Short(1, 2, 3, 4, 5). Bool(true, fal...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testBit() throws Exception { assertArrayEquals(new byte[]{1}, binStart().Bit(1).end().toByteArray()); } #location 3 #vulnerability type RESOURCE_LEAK
#fixed code @Test public void testBit() throws Exception { assertArrayEquals(new byte[]{1}, BeginBin().Bit(1).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public JBBPOut Bin(final Object object) throws IOException { if (this.processCommands) { Field[] orderedFields = null; final Map<Class<?>, Field[]> fieldz; if (cachedFields == null) { fieldz = new HashMap<Class<?>, Field[]>(); cache...
#fixed code public JBBPOut Bin(final Object object) throws IOException { if (this.processCommands) { JBBPUtils.assertNotNull(object, "Object must not be null"); Field[] orderedFields = null; final Map<Class<?>, Field[]> fieldz; if (cachedFields == null) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testBitArrayAsInts() throws Exception { assertArrayEquals(new byte[]{(byte) 0xE3}, binStart().Bit(1, 3, 0, 2, 4, 1, 3, 7).end().toByteArray()); assertArrayEquals(new byte[]{(byte) 0x0B}, binStart().Bit(1, 3, 0, 7).end().toByteArray()); } ...
#fixed code @Test public void testBitArrayAsInts() throws Exception { assertArrayEquals(new byte[]{(byte) 0xE3}, BeginBin().Bit(1, 3, 0, 2, 4, 1, 3, 7).End().toByteArray()); assertArrayEquals(new byte[]{(byte) 0x0B}, BeginBin().Bit(1, 3, 0, 7).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testShort_LittleEndian() throws Exception { assertArrayEquals(new byte []{0x02,01}, binStart().ByteOrder(JBBPByteOrder.LITTLE_ENDIAN).Short(0x0102).end().toByteArray()); } #location 3 #vul...
#fixed code @Test public void testShort_LittleEndian() throws Exception { assertArrayEquals(new byte []{0x02,01}, BeginBin().ByteOrder(JBBPByteOrder.LITTLE_ENDIAN).Short(0x0102).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testExceptionForOperatioOverEndedProcess() throws Exception { final JBBPOut out = binStart(); out.ByteOrder(JBBPByteOrder.BIG_ENDIAN).Long(0x0102030405060708L).end(); try{ out.Align(); fail("Must throw ISE"); }catch(IllegalS...
#fixed code @Test public void testExceptionForOperatioOverEndedProcess() throws Exception { final JBBPOut out = BeginBin(); out.ByteOrder(JBBPByteOrder.BIG_ENDIAN).Long(0x0102030405060708L).End(); try{ out.Align(); fail("Must throw ISE"); }catch(IllegalStateEx...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testBitArrayAsBytes() throws Exception { assertArrayEquals(new byte[]{(byte) 0xE3}, binStart().Bit(new byte[]{(byte) 1, (byte) 3, (byte) 0, (byte) 2, (byte) 4, (byte) 1, (byte) 3, (byte) 7}).end().toByteArray()); assertArrayEquals(new byte[]{(b...
#fixed code @Test public void testBitArrayAsBytes() throws Exception { assertArrayEquals(new byte[]{(byte) 0xE3}, BeginBin().Bit(new byte[]{(byte) 1, (byte) 3, (byte) 0, (byte) 2, (byte) 4, (byte) 1, (byte) 3, (byte) 7}).End().toByteArray()); assertArrayEquals(new byte[]{(byte) 0...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testAlign() throws Exception { assertArrayEquals(new byte[]{(byte) 0x01, (byte) 0xFF}, new JBBPOut(new ByteArrayOutputStream()).Bit(1).Align().Byte(0xFF).End().toByteArray()); } #location 3 ...
#fixed code @Test public void testAlign() throws Exception { assertArrayEquals(new byte[]{(byte) 0x01, (byte) 0xFF}, JBBPOut.BeginBin().Bit(1).Align().Byte(0xFF).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testIntArray() throws Exception { assertArrayEquals(new byte []{0x01,02,0x03,0x04,0x05,0x06,0x07,0x08}, binStart().Int(0x01020304, 0x05060708).end().toByteArray()); } #location 3 #vulnerab...
#fixed code @Test public void testIntArray() throws Exception { assertArrayEquals(new byte []{0x01,02,0x03,0x04,0x05,0x06,0x07,0x08}, BeginBin().Int(0x01020304, 0x05060708).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testShortArray_AsShortArray() throws Exception { assertArrayEquals(new byte[]{1, 2, 3, 4}, binStart().Short(new short[]{(short)0x0102, (short)0x0304}).end().toByteArray()); } #location 3 #...
#fixed code @Test public void testShortArray_AsShortArray() throws Exception { assertArrayEquals(new byte[]{1, 2, 3, 4}, BeginBin().Short(new short[]{(short)0x0102, (short)0x0304}).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testGetLineSeparator() throws Exception { assertEquals("hello", new JBBPTextWriter(writer, JBBPByteOrder.BIG_ENDIAN, "hello", 11, "", "", "", "").getLineSeparator()); } #location 3 #vulner...
#fixed code @Test public void testGetLineSeparator() throws Exception { assertEquals("hello", new JBBPTextWriter(writer, JBBPByteOrder.BIG_ENDIAN, "hello", 11, "", "", "","", "").getLineSeparator()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testShort() throws Exception { assertArrayEquals(new byte []{0x01,02}, binStart().Short(0x0102).end().toByteArray()); } #location 3 #vulnerability type RESOURCE_LEAK
#fixed code @Test public void testShort() throws Exception { assertArrayEquals(new byte []{0x01,02}, BeginBin().Short(0x0102).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testBits_Int() throws Exception { assertArrayEquals(new byte[]{0xD}, binStart().Bits(JBBPNumberOfBits.BITS_4, 0xFD).end().toByteArray()); } #location 3 #vulnerability type RESOURCE_LEAK
#fixed code @Test public void testBits_Int() throws Exception { assertArrayEquals(new byte[]{0xD}, BeginBin().Bits(JBBPNumberOfBits.BITS_4, 0xFD).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testInt_LittleEndian() throws Exception { assertArrayEquals(new byte[]{0x04, 0x03, 0x02, 0x01}, binStart().ByteOrder(JBBPByteOrder.LITTLE_ENDIAN).Int(0x01020304).end().toByteArray()); } #location 3 ...
#fixed code @Test public void testInt_LittleEndian() throws Exception { assertArrayEquals(new byte[]{0x04, 0x03, 0x02, 0x01}, BeginBin().ByteOrder(JBBPByteOrder.LITTLE_ENDIAN).Int(0x01020304).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testEmptyArray() throws Exception { assertEquals(0, new JBBPOut(new ByteArrayOutputStream()).End().toByteArray().length); } #location 3 #vulnerability type RESOURCE_LEAK
#fixed code @Test public void testEmptyArray() throws Exception { assertEquals(0, JBBPOut.BeginBin().End().toByteArray().length); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testShortArray_AsIntegers_LittleEndian() throws Exception { assertArrayEquals(new byte []{2,1,4,3}, binStart().ByteOrder(JBBPByteOrder.LITTLE_ENDIAN).Short(0x0102,0x0304).end().toByteArray()); } #location 3 ...
#fixed code @Test public void testShortArray_AsIntegers_LittleEndian() throws Exception { assertArrayEquals(new byte []{2,1,4,3}, BeginBin().ByteOrder(JBBPByteOrder.LITTLE_ENDIAN).Short(0x0102,0x0304).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public byte[] readByteArray(final int items) throws IOException { int pos = 0; if (items < 0) { byte[] buffer = new byte[INITIAL_ARRAY_BUFFER_SIZE]; // till end while (true) { final int next = read(); if (next < 0) { bre...
#fixed code public byte[] readByteArray(final int items) throws IOException { return _readArray(items, null); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testBitArrayAsBooleans() throws Exception { assertArrayEquals(new byte[]{(byte) 0xE3}, binStart().Bit(true, true, false, false, false, true, true, true).end().toByteArray()); assertArrayEquals(new byte[]{(byte) 0x0B}, binStart().Bit(true, true,...
#fixed code @Test public void testBitArrayAsBooleans() throws Exception { assertArrayEquals(new byte[]{(byte) 0xE3}, BeginBin().Bit(true, true, false, false, false, true, true, true).End().toByteArray()); assertArrayEquals(new byte[]{(byte) 0x0B}, BeginBin().Bit(true, true, false...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testLongArray() throws Exception { assertArrayEquals(new byte []{0x01,02,0x03,0x04,0x05,0x06,0x07,0x08, 0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18}, binStart().Long(0x0102030405060708L,0x1112131415161718L).end().toByteArray()); } ...
#fixed code @Test public void testLongArray() throws Exception { assertArrayEquals(new byte []{0x01,02,0x03,0x04,0x05,0x06,0x07,0x08, 0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18}, BeginBin().Long(0x0102030405060708L,0x1112131415161718L).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testAlignWithArgument() throws Exception { assertEquals(0, new JBBPOut(new ByteArrayOutputStream()).Align(2).End().toByteArray().length); assertArrayEquals(new byte[]{(byte) 0x01, (byte) 0xFF}, new JBBPOut(new ByteArrayOutputStream()).Bit(1).Al...
#fixed code @Test public void testAlignWithArgument() throws Exception { assertEquals(0, JBBPOut.BeginBin().Align(2).End().toByteArray().length); assertArrayEquals(new byte[]{(byte) 0x01, (byte) 0xFF}, JBBPOut.BeginBin().Bit(1).Align(1).Byte(0xFF).End().toByteArray()); assert...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testBeginBin() throws Exception { assertArrayEquals(new byte[]{1}, BeginBin().Byte(1).End().toByteArray()); assertArrayEquals(new byte[]{0x02, 0x01}, BeginBin(JBBPByteOrder.LITTLE_ENDIAN).Short(0x0102).End().toByteArray()); assertArrayEqual...
#fixed code @Test public void testBeginBin() throws Exception { assertArrayEquals(new byte[]{1}, BeginBin().Byte(1).End().toByteArray()); assertArrayEquals(new byte[]{0x02, 0x01}, BeginBin(JBBPByteOrder.LITTLE_ENDIAN).Short(0x0102).End().toByteArray()); assertArrayEquals(new ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testShort_BigEndian() throws Exception { assertArrayEquals(new byte []{0x01,02}, binStart().ByteOrder(JBBPByteOrder.BIG_ENDIAN).Short(0x0102).end().toByteArray()); } #location 3 #vulnerabi...
#fixed code @Test public void testShort_BigEndian() throws Exception { assertArrayEquals(new byte []{0x01,02}, BeginBin().ByteOrder(JBBPByteOrder.BIG_ENDIAN).Short(0x0102).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testBits_ByteArray() throws Exception { assertArrayEquals(new byte[]{(byte) 0xED}, binStart().Bits(JBBPNumberOfBits.BITS_4, (byte) 0xFD, (byte) 0x8E).end().toByteArray()); } #location 3 #v...
#fixed code @Test public void testBits_ByteArray() throws Exception { assertArrayEquals(new byte[]{(byte) 0xED}, BeginBin().Bits(JBBPNumberOfBits.BITS_4, (byte) 0xFD, (byte) 0x8E).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testLong_BigEndian() throws Exception { assertArrayEquals(new byte []{0x01, 02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}, binStart().ByteOrder(JBBPByteOrder.BIG_ENDIAN).Long(0x0102030405060708L).end().toByteArray()); } #lo...
#fixed code @Test public void testLong_BigEndian() throws Exception { assertArrayEquals(new byte []{0x01, 02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}, BeginBin().ByteOrder(JBBPByteOrder.BIG_ENDIAN).Long(0x0102030405060708L).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public byte[] readBitsArray(final int items, final JBBPBitNumber bitNumber) throws IOException { int pos = 0; if (items < 0) { byte[] buffer = new byte[INITIAL_ARRAY_BUFFER_SIZE]; // till end while (true) { final int next = readBits(bitNu...
#fixed code public byte[] readBitsArray(final int items, final JBBPBitNumber bitNumber) throws IOException { return _readArray(items, bitNumber); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testInt_BigEndian() throws Exception { assertArrayEquals(new byte []{0x01,0x02,0x03,0x04}, binStart().ByteOrder(JBBPByteOrder.BIG_ENDIAN).Int(0x01020304).end().toByteArray()); } #location 3 ...
#fixed code @Test public void testInt_BigEndian() throws Exception { assertArrayEquals(new byte []{0x01,0x02,0x03,0x04}, BeginBin().ByteOrder(JBBPByteOrder.BIG_ENDIAN).Int(0x01020304).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testComplexWriting_1() throws Exception { final ByteArrayOutputStream buffer = new ByteArrayOutputStream(16384); final JBBPOut begin = new JBBPOut(buffer); begin. Bit(1, 2, 3, 0). Bit(true, false, true). ...
#fixed code @Test public void testComplexWriting_1() throws Exception { final byte [] array = BeginBin(). Bit(1, 2, 3, 0). Bit(true, false, true). Align(). Byte(5). Short(1, 2, 3, 4, 5). Bool(true, fal...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testBit_LSB0() throws Exception { assertArrayEquals(new byte[]{(byte) 0x01}, binStart(JBBPByteOrder.BIG_ENDIAN, JBBPBitOrder.LSB0).Bit(1).end().toByteArray()); } #location 3 #vulnerability...
#fixed code @Test public void testBit_LSB0() throws Exception { assertArrayEquals(new byte[]{(byte) 0x01}, BeginBin(JBBPByteOrder.BIG_ENDIAN, JBBPBitOrder.LSB0).Bit(1).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testShortArray_AsIntegers_BigEndian() throws Exception { assertArrayEquals(new byte []{1,2,3,4}, binStart().ByteOrder(JBBPByteOrder.BIG_ENDIAN).Short(0x0102,0x0304).end().toByteArray()); } #location 3 ...
#fixed code @Test public void testShortArray_AsIntegers_BigEndian() throws Exception { assertArrayEquals(new byte []{1,2,3,4}, BeginBin().ByteOrder(JBBPByteOrder.BIG_ENDIAN).Short(0x0102,0x0304).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testBitArrayAsBooleans() throws Exception { assertArrayEquals(new byte[]{(byte) 0xE3}, binStart().Bit(true, true, false, false, false, true, true, true).end().toByteArray()); assertArrayEquals(new byte[]{(byte) 0x0B}, binStart().Bit(true, true,...
#fixed code @Test public void testBitArrayAsBooleans() throws Exception { assertArrayEquals(new byte[]{(byte) 0xE3}, BeginBin().Bit(true, true, false, false, false, true, true, true).End().toByteArray()); assertArrayEquals(new byte[]{(byte) 0x0B}, BeginBin().Bit(true, true, false...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testBits_IntArray() throws Exception { assertArrayEquals(new byte[]{(byte) 0xED}, binStart().Bits(JBBPNumberOfBits.BITS_4, 0xFD, 0xFE).end().toByteArray()); } #location 3 #vulnerability ty...
#fixed code @Test public void testBits_IntArray() throws Exception { assertArrayEquals(new byte[]{(byte) 0xED}, BeginBin().Bits(JBBPNumberOfBits.BITS_4, 0xFD, 0xFE).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testParse_StructArray_IgnoredForZeroLength() throws Exception { final JBBPFieldStruct parsed = JBBPParser.prepare("byte len; sss [len] { byte a; byte b; byte c;} ushort;").parse(new byte[]{0x0, 0x01, (byte) 0x02}); assertNull(parsed.findFieldF...
#fixed code @Test public void testParse_StructArray_IgnoredForZeroLength() throws Exception { final JBBPFieldStruct parsed = JBBPParser.prepare("byte len; sss [len] { byte a; byte b; byte c;} ushort;").parse(new byte[]{0x0, 0x01, (byte) 0x02}); assertEquals(0,parsed.findFieldFor...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public int read(final byte[] array, final int offset, final int length) throws IOException { if (this.bitsInBuffer == 0) { int readBytes; readBytes = 0; int i = offset; int y = length; while (y > 0) { int value = this....
#fixed code @Override public int read(final byte[] array, final int offset, final int length) throws IOException { if (this.bitsInBuffer == 0) { int readBytes = 0; int tmpoffset = offset; int tmplen = length; while (tmplen > 0) { int read = this.in.rea...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private byte[] callWrite(final Object instance) throws Exception { final ByteArrayOutputStream bout = new ByteArrayOutputStream(); instance.getClass().getMethod("write", JBBPBitOutputStream.class).invoke(instance, new JBBPBitOutputStream(bout)); bout.close(); ...
#fixed code private byte[] callWrite(final Object instance) throws Exception { final ByteArrayOutputStream bout = new ByteArrayOutputStream(); final JBBPBitOutputStream bitout = new JBBPBitOutputStream(bout); instance.getClass().getMethod("write", JBBPBitOutputStream.class).inv...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public int readBits(final JBBPBitNumber numOfBitsToRead) throws IOException { int result; final int numOfBitsAsNumber = numOfBitsToRead.getBitNumber(); if (this.bitsInBuffer == 0 && numOfBitsAsNumber == 8) { result = this.readByteFromStream(); re...
#fixed code public int readBits(final JBBPBitNumber numOfBitsToRead) throws IOException { int result; final int numOfBitsAsNumber = numOfBitsToRead.getBitNumber(); if (this.bitsInBuffer == 0 && numOfBitsAsNumber == 8) { result = this.readByteFromStream(); this.byt...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testExternalStreamButNoByteArrayOutputStream() throws Exception { final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); final DataOutputStream dout = new DataOutputStream(buffer); assertNull(binStart(dout).Byte(1,2,3).end()...
#fixed code @Test public void testExternalStreamButNoByteArrayOutputStream() throws Exception { final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); final DataOutputStream dout = new DataOutputStream(buffer); assertNull(BeginBin(dout).Byte(1,2,3).End()); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testAlignWithArgument() throws Exception { assertEquals(0, new JBBPOut(new ByteArrayOutputStream()).Align(2).End().toByteArray().length); assertArrayEquals(new byte[]{(byte) 0x01, (byte) 0xFF}, new JBBPOut(new ByteArrayOutputStream()).Bit(1).Al...
#fixed code @Test public void testAlignWithArgument() throws Exception { assertEquals(0, JBBPOut.BeginBin().Align(2).End().toByteArray().length); assertArrayEquals(new byte[]{(byte) 0x01, (byte) 0xFF}, JBBPOut.BeginBin().Bit(1).Align(1).Byte(0xFF).End().toByteArray()); assert...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testShortArray_AsIntegers() throws Exception { assertArrayEquals(new byte []{1,2,3,4}, binStart().Short(0x0102,0x0304).end().toByteArray()); } #location 3 #vulnerability type RESOURCE_LEAK
#fixed code @Test public void testShortArray_AsIntegers() throws Exception { assertArrayEquals(new byte []{1,2,3,4}, BeginBin().Short(0x0102,0x0304).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testInt() throws Exception { assertArrayEquals(new byte []{0x01,02,0x03,0x04}, binStart().Int(0x01020304).end().toByteArray()); } #location 3 #vulnerability type RESOURCE_LEAK
#fixed code @Test public void testInt() throws Exception { assertArrayEquals(new byte []{0x01,02,0x03,0x04}, BeginBin().Int(0x01020304).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testByteArrayAsInts() throws Exception { assertArrayEquals(new byte[]{1, 3, 0, 2, 4, 1, 3, 7}, binStart().Byte(1, 3, 0, 2, 4, 1, 3, 7).end().toByteArray()); } #location 3 #vulnerability ty...
#fixed code @Test public void testByteArrayAsInts() throws Exception { assertArrayEquals(new byte[]{1, 3, 0, 2, 4, 1, 3, 7}, BeginBin().Byte(1, 3, 0, 2, 4, 1, 3, 7).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testLong() throws Exception { assertArrayEquals(new byte []{0x01,02,0x03,0x04,0x05,0x06,0x07,0x08}, binStart().Long(0x0102030405060708L).end().toByteArray()); } #location 3 #vulnerability ...
#fixed code @Test public void testLong() throws Exception { assertArrayEquals(new byte []{0x01,02,0x03,0x04,0x05,0x06,0x07,0x08}, BeginBin().Long(0x0102030405060708L).End().toByteArray()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testComplexWriting_1() throws Exception { final ByteArrayOutputStream buffer = new ByteArrayOutputStream(16384); final JBBPOut begin = new JBBPOut(buffer); begin. Bit(1, 2, 3, 0). Bit(true, false, true). ...
#fixed code @Test public void testComplexWriting_1() throws Exception { final byte [] array = BeginBin(). Bit(1, 2, 3, 0). Bit(true, false, true). Align(). Byte(5). Short(1, 2, 3, 4, 5). Bool(true, fal...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public BigDecimal convert(Currency from, Currency to, BigDecimal amount) { Map<Currency, BigDecimal> rates = getCurrentRates(); BigDecimal baseRatio = rates.get(to).divide(rates.get(from), 4, RoundingMode.HALF_UP); return amount.multiply(baseRatio); } ...
#fixed code @Override public BigDecimal convert(Currency from, Currency to, BigDecimal amount) { Assert.notNull(amount); Map<Currency, BigDecimal> rates = getCurrentRates(); BigDecimal ratio = rates.get(to).divide(rates.get(from), 4, RoundingMode.HALF_UP); return amount.multiply...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void debugLocal() { if (!traceDebugEnabled) { return; } System.out.println("---------------- Trace Information ---------------"); String traceId = getTraceId(); String spanId = getSpanId(); System.out.p...
#fixed code public void debugLocal() { if (!traceDebugEnabled) { return; } System.out.println("---------------- Trace Information ---------------"); String traceId = getTraceId(); String spanId = getSpanId(); System.out.println...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean apply(Server server, Map<String, String> metadata) { GatewayStrategyContext context = GatewayStrategyContext.getCurrentContext(); String token = context.getExchange().getRequest().getHeaders().getFirst("token"); // St...
#fixed code @Override public boolean apply(Server server, Map<String, String> metadata) { // 1.对Rest调用传来的Header的路由Version做策略。注意这个Version不是灰度发布的Version boolean enabled = super.apply(server, metadata); if (!enabled) { return false; } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Server choose(Object key) { WeightFilterEntity weightFilterEntity = weightRandomLoadBalance.getWeightFilterEntity(); if (!weightFilterEntity.hasWeight()) { return super.choose(key); } List<Server> eligibl...
#fixed code @Override public Server choose(Object key) { WeightFilterEntity weightFilterEntity = weightRandomLoadBalance.getWeightFilterEntity(); if (weightFilterEntity == null) { return super.choose(key); } if (!weightFilterEntity.hasWeig...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void applyVersionFilter(String consumerServiceId, String consumerServiceVersion, String providerServiceId, List<ServiceInstance> instances) { // 如果消费端未配置版本号,那么它可以调用提供端所有服务,需要符合规范,极力避免该情况发生 if (StringUtils.isEmpty(consumerServiceVersion)) { ...
#fixed code private void applyVersionFilter(String consumerServiceId, String consumerServiceVersion, String providerServiceId, List<ServiceInstance> instances) { // 如果消费端未配置版本号,那么它可以调用提供端所有服务,需要符合规范,极力避免该情况发生 if (StringUtils.isEmpty(consumerServiceVersion)) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void mdcLocal() { if (!traceLoggerEnabled) { return; } Map<String, String> customizationMap = getCustomizationMap(); if (MapUtils.isNotEmpty(customizationMap)) { for (Map.Entry<String, String> entry : custo...
#fixed code public void mdcLocal() { if (!traceLoggerEnabled) { return; } Map<String, String> customizationMap = getCustomizationMap(); if (MapUtils.isNotEmpty(customizationMap)) { for (Map.Entry<String, String> entry : customizati...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Server choose(Object key) { WeightFilterEntity weightFilterEntity = weightRandomLoadBalance.getWeightFilterEntity(); if (!weightFilterEntity.hasWeight()) { return super.choose(key); } List<Server> eligibl...
#fixed code @Override public Server choose(Object key) { WeightFilterEntity weightFilterEntity = weightRandomLoadBalance.getWeightFilterEntity(); if (weightFilterEntity == null) { return super.choose(key); } if (!weightFilterEntity.hasWeig...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void mdcHeader() { if (!traceLoggerEnabled) { return; } Map<String, String> customizationMap = getCustomizationMap(); if (MapUtils.isNotEmpty(customizationMap)) { for (Map.Entry<String, String> entry : cust...
#fixed code public void mdcHeader() { if (!traceLoggerEnabled) { return; } Map<String, String> customizationMap = getCustomizationMap(); if (MapUtils.isNotEmpty(customizationMap)) { for (Map.Entry<String, String> entry : customizat...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void debugHeader() { if (!traceDebugEnabled) { return; } System.out.println("---------------- Trace Information ---------------"); String traceId = getTraceId(); String spanId = getSpanId(); System.out....
#fixed code public void debugHeader() { if (!traceDebugEnabled) { return; } System.out.println("---------------- Trace Information ---------------"); String traceId = getTraceId(); String spanId = getSpanId(); System.out.printl...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private String createSpanId() { if (System.getProperties().get("skywalking.agent.service_name") == null) { return null; } try { Object traceContext = StrategySkywalkingTracerResolver.invokeStaticMethod("org.apache.skywalk...
#fixed code private String createSpanId() { try { return StrategySkywalkingTracerResolver.getSpanId(); } catch (Exception e) { return null; } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private boolean applyFromHeader(Server server, Map<String, String> metadata) { String token = zuulStrategyContextHolder.getHeader("token"); String serviceId = pluginAdapter.getServerServiceId(server); LOG.info("Zuul端负载均衡用户定制触发:token={}, serviceI...
#fixed code private boolean applyFromHeader(Server server, Map<String, String> metadata) { String mobile = zuulStrategyContextHolder.getHeader("mobile"); String version = metadata.get(DiscoveryConstant.VERSION); String serviceId = pluginAdapter.getServerServiceId(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("rawtypes") private void parseStrategyCondition(Element element, List<StrategyConditionEntity> strategyConditionEntityList) { for (Iterator elementIterator = element.elementIterator(); elementIterator.hasNext();) { Object childE...
#fixed code @SuppressWarnings("rawtypes") private void parseStrategyCondition(Element element, List<StrategyConditionEntity> strategyConditionEntityList) { for (Iterator elementIterator = element.elementIterator(); elementIterator.hasNext();) { Object childElement...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void debugTraceLocal() { if (!traceDebugEnabled) { return; } System.out.println("---------------- Trace Information ---------------"); Map<String, String> debugTraceMap = getDebugTraceMap(); if (MapUtils.isNotE...
#fixed code public void debugTraceLocal() { if (!traceDebugEnabled) { return; } System.out.println("---------------- Trace Information ---------------"); String traceId = getTraceId(); String spanId = getSpanId(); System.out.pr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private boolean applyFromHeader(Server server, Map<String, String> metadata) { String token = gatewayStrategyContextHolder.getHeader("token"); String serviceId = pluginAdapter.getServerServiceId(server); LOG.info("Gateway端负载均衡用户定制触发:token={}, se...
#fixed code private boolean applyFromHeader(Server server, Map<String, String> metadata) { String mobile = gatewayStrategyContextHolder.getHeader("mobile"); String version = metadata.get(DiscoveryConstant.VERSION); String serviceId = pluginAdapter.getServerService...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public int compare(@Nullable Object left, @Nullable Object right) throws SpelEvaluationException { if (left == null) { return 0; } try { BigDecimal leftValue = new BigDecimal(left.toString()); Bi...
#fixed code @Override public int compare(@Nullable Object left, @Nullable Object right) throws SpelEvaluationException { if (left == null) { return right == null ? 0 : -1; } else if (right == null) { return 1; } try { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void debugTraceHeader() { if (!traceDebugEnabled) { return; } System.out.println("---------------- Trace Information ---------------"); Map<String, String> debugTraceMap = getDebugTraceMap(); if (MapUtils.isNot...
#fixed code public void debugTraceHeader() { if (!traceDebugEnabled) { return; } System.out.println("---------------- Trace Information ---------------"); String traceId = getTraceId(); String spanId = getSpanId(); System.out.p...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("rawtypes") @Override protected void parseRoot(Element element) { LOG.info("Start to parse rule xml..."); int registerElementCount = element.elements(ConfigConstant.REGISTER_ELEMENT_NAME).size(); if (registerElementCoun...
#fixed code @SuppressWarnings("rawtypes") @Override protected void parseRoot(Element element) { LOG.info("Start to parse rule xml..."); int registerElementCount = element.elements(ConfigConstant.REGISTER_ELEMENT_NAME).size(); if (registerElementCount > 1)...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void update(N node) { Point2D location = layoutModel.apply(node); if (!this.getLayoutArea().contains(location)) { log.trace(location + " outside of spatial " + this.getLayoutArea()); this.setBounds(this.getUnion(this.getLayoutArea(),...
#fixed code @Override public void update(N node) { Point2D location = layoutModel.apply(node); if (!this.getLayoutArea().contains(location)) { log.trace(location + " outside of spatial " + this.getLayoutArea()); this.setBounds(this.getUnion(this.getLayoutArea(), locat...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testBasicWrite() throws IOException, ParserConfigurationException, SAXException { Network<String, Number> g = TestGraphs.createTestGraph(true); GraphMLWriter<String, Number> gmlw = new GraphMLWriter<String, Number>(); Function<Number, String> edge_...
#fixed code public void testBasicWrite() throws IOException, ParserConfigurationException, SAXException { Network<String, Number> g = TestGraphs.createTestGraph(true); GraphMLWriter<String, Number> gmlw = new GraphMLWriter<String, Number>(); Function<Number, String> edge_weight...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected V getClosest( SpatialQuadTree<V> spatial, LayoutModel<V, Point2D> layoutModel, double x, double y) { SpatialQuadTree<V> leaf = spatial.getContainingQuadTreeLeaf(x, y); double diameter = leaf.getLayoutArea().getWidth(); double radius = diameter ...
#fixed code protected V getClosest( SpatialQuadTree<V> spatial, LayoutModel<V, Point2D> layoutModel, double x, double y) { // move the x,y to layout coordinates Point2D pickPointInView = new Point2D.Double(x, y); Point2D pickPointInLayout = vv.getRenderContext() ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testBasicWrite() throws IOException, ParserConfigurationException, SAXException { Network<String, Number> g = TestGraphs.createTestGraph(true); GraphMLWriter<String, Number> gmlw = new GraphMLWriter<String, Number>(); Function<Number, String> edge_...
#fixed code public void testBasicWrite() throws IOException, ParserConfigurationException, SAXException { Network<String, Number> g = TestGraphs.createTestGraph(true); GraphMLWriter<String, Number> gmlw = new GraphMLWriter<String, Number>(); Function<Number, String> edge_weight...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code String findFileOnClasspath(String fileName) { URL url = getClass().getClassLoader().getResource(fileName); if (url == null) { throw new IllegalArgumentException("Cannot find file " + fileName + " on classpath"); } Path path = ClasspathPathResolver.ur...
#fixed code void testEchoStringWithEncoding(String encoding) { String sent = randomUnicodeString(100); Buffer buffSent = new Buffer(sent, encoding); testEcho(sock -> sock.write(sent, encoding), buff -> buffersEqual(buffSent, buff), buffSent.length()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Before @SuppressWarnings({ "unchecked", "deprecation" }) public void before() throws IllegalArgumentException, IllegalAccessException, SQLException, SecurityException, NoSuchFieldException, CloneNotSupportedException{ mockConfig = EasyMock.createNiceMock(BoneCPConfig....
#fixed code @Before @SuppressWarnings({ "unchecked", "deprecation" }) public void before() throws IllegalArgumentException, IllegalAccessException, SQLException, SecurityException, NoSuchFieldException, CloneNotSupportedException{ driver = new MockJDBCDriver(new MockJDBCAnswer() { p...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testCreatePool() throws SQLException, ClassNotFoundException { BoneCPConfig mockConfig = createNiceMock(BoneCPConfig.class); expect(mockConfig.getPartitionCount()).andReturn(1).anyTimes(); expect(mockConfig.getMaxConnectionsPerPartition()).andRet...
#fixed code @Test public void testCreatePool() throws SQLException, ClassNotFoundException, CloneNotSupportedException { BoneCPConfig mockConfig = createNiceMock(BoneCPConfig.class); expect(mockConfig.getPartitionCount()).andReturn(1).anyTimes(); expect(mockConfig.getMaxConnections...
Below is the vulnerable code, please generate the patch based on the following information.