input stringlengths 205 73.3k | output stringlengths 64 73.2k | instruction stringclasses 1
value |
|---|---|---|
#vulnerable code
private PhotometricInterpreter getPhotometricInterpreter(
final TiffDirectory directory, final int photometricInterpretation,
final int bitsPerPixel, final int bitsPerSample[], final int predictor,
final int samplesPerPixel, final int... | #fixed code
private PhotometricInterpreter getPhotometricInterpreter(
final TiffDirectory directory, final int photometricInterpretation,
final int bitsPerPixel, final int bitsPerSample[], final int predictor,
final int samplesPerPixel, final int width... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static byte[] decompressModifiedHuffman(final byte[] compressed,
final int width, final int height) throws ImageReadException {
final BitInputStreamFlexible inputStream = new BitInputStreamFlexible(
new ByteArrayInputStream(com... | #fixed code
public static byte[] decompressModifiedHuffman(final byte[] compressed,
final int width, final int height) throws ImageReadException {
try (ByteArrayInputStream baos = new ByteArrayInputStream(compressed);
BitInputStreamFlexible inputStream... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected List<IptcBlock> parseAllBlocks(byte bytes[], boolean verbose,
boolean strict) throws ImageReadException, IOException {
List<IptcBlock> blocks = new ArrayList<IptcBlock>();
BinaryInputStream bis = new BinaryInputStream(bytes, APP13_... | #fixed code
protected List<IptcBlock> parseAllBlocks(byte bytes[], boolean verbose,
boolean strict) throws ImageReadException, IOException {
List<IptcBlock> blocks = new ArrayList<IptcBlock>();
BinaryInputStream bis = null;
try {
bis = new... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void changeExifMetadata(final File jpegImageFile, final File dst)
throws IOException, ImageReadException, ImageWriteException {
OutputStream os = null;
boolean canThrow = false;
try {
TiffOutputSet outputSet = null;... | #fixed code
public void changeExifMetadata(final File jpegImageFile, final File dst)
throws IOException, ImageReadException, ImageWriteException {
try (FileOutputStream fos = new FileOutputStream(dst);
OutputStream os = new BufferedOutputStrea... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testRemove() throws Exception {
final ByteSource byteSource = new ByteSourceFile(imageFile);
final Map<String, Object> params = new HashMap<String, Object>();
final boolean ignoreImageData = isPhilHarveyTestImage(imageFile)... | #fixed code
@Test
public void testRemove() throws Exception {
final ByteSource byteSource = new ByteSourceFile(imageFile);
final Map<String, Object> params = new HashMap<String, Object>();
final boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testImaging144() throws Exception {
tiffOutputSet.setGPSInDegrees(1.0, 1.0);
TiffOutputDirectory gpsDirectory = tiffOutputSet.getGPSDirectory();
TiffOutputField gpsVersionId = gpsDirectory.findField(GpsTagConstants.GPS_TAG_... | #fixed code
@Test
public void testImaging144() throws Exception {
tiffOutputSet.setGPSInDegrees(1.0, 1.0);
TiffOutputField gpsVersionId = tiffOutputSet.findField(GpsTagConstants.GPS_TAG_GPS_VERSION_ID);
assertNotNull(gpsVersionId);
assertTrue(gpsVers... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void test() throws Exception {
String imagesFolderPath = FilenameUtils
.separatorsToSystem("src\\test\\data\\images\\png\\3");
File imagesFolder = new File(imagesFolderPath);
assertTrue(imagesFolder.exists() && imagesFolder... | #fixed code
public void test() throws Exception {
String imagesFolderPath = FilenameUtils
.separatorsToSystem("src\\test\\data\\images\\png\\3");
File imagesFolder = new File(imagesFolderPath);
assertTrue(imagesFolder.exists() && imagesFolder.isDir... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testAll5x2Images() {
int[] combinations = new int[10];
BufferedImage image = new BufferedImage(5, 2, BufferedImage.TYPE_INT_RGB);
do {
for (int x = 0; x < 5; x++) {
if (combinations[x] == 0) {
... | #fixed code
public void testAll5x2Images() {
int[] combinations = new int[10];
BufferedImage image = new BufferedImage(5, 2, BufferedImage.TYPE_INT_RGB);
do {
for (int x = 0; x < 5; x++) {
if (combinations[x] == 0) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testAddIptcData() throws Exception {
final ByteSource byteSource = new ByteSourceFile(imageFile);
final Map<String, Object> params = new HashMap<String, Object>();
final boolean ignoreImageData = isPhilHarveyTestImage(image... | #fixed code
@Test
public void testAddIptcData() throws Exception {
final ByteSource byteSource = new ByteSourceFile(imageFile);
final Map<String, Object> params = new HashMap<String, Object>();
final boolean ignoreImageData = isPhilHarveyTestImage(imageFile);... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void interpretStrip(
final ImageBuilder imageBuilder,
final byte[] bytes,
final int pixelsPerStrip,
final int yLimit) throws ImageReadException, IOException {
if (y >= yLimit) {
return;
... | #fixed code
private void interpretStrip(
final ImageBuilder imageBuilder,
final byte[] bytes,
final int pixelsPerStrip,
final int yLimit) throws ImageReadException, IOException {
if (y >= yLimit) {
return;
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void checkGetICCProfileBytes(final File imageFile, final byte[] imageFileBytes)
throws Exception {
// check guessFormat()
final byte iccBytesFile[] = Imaging.getICCProfileBytes(imageFile);
final byte iccBytesBytes[] = Imaging.... | #fixed code
public void checkGetICCProfileBytes(final File imageFile, final byte[] imageFileBytes)
throws Exception {
// check guessFormat()
final byte iccBytesFile[] = Imaging.getICCProfileBytes(imageFile);
final byte iccBytesBytes[] = Imaging.getICC... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected List<IptcBlock> parseAllBlocks(byte bytes[], boolean verbose,
boolean strict) throws ImageReadException, IOException {
List<IptcBlock> blocks = new ArrayList<IptcBlock>();
BinaryInputStream bis = new BinaryInputStream(bytes, APP13_... | #fixed code
protected List<IptcBlock> parseAllBlocks(byte bytes[], boolean verbose,
boolean strict) throws ImageReadException, IOException {
List<IptcBlock> blocks = new ArrayList<IptcBlock>();
BinaryInputStream bis = null;
try {
bis = new... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public byte[] compress(final byte[] bytes) throws IOException {
FastByteArrayOutputStream baos = null;
boolean canThrow = false;
try {
baos = new FastByteArrayOutputStream(
bytes.length * 2); // max length 1 extra ... | #fixed code
public byte[] compress(final byte[] bytes) throws IOException {
// max length 1 extra byte for every 128
try (FastByteArrayOutputStream baos = new FastByteArrayOutputStream(bytes.length * 2)) {
int ptr = 0;
while (ptr < bytes.length) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void removeExifTag(final File jpegImageFile, final File dst) throws IOException,
ImageReadException, ImageWriteException {
OutputStream os = null;
boolean canThrow = false;
try {
TiffOutputSet outputSet = null;
... | #fixed code
public void removeExifTag(final File jpegImageFile, final File dst) throws IOException,
ImageReadException, ImageWriteException {
try (FileOutputStream fos = new FileOutputStream(dst);
OutputStream os = new BufferedOutputStream(fos)) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void performTest(final String name) {
final File target = new File(name);
final Formatter fmt = new Formatter(System.out);
double sumTime = 0;
int n = 1;
for (int i = 0; i < 10; i++) {
try {
By... | #fixed code
private void performTest(final String name) {
final File target = new File(name);
final Formatter fmt = new Formatter(System.out);
double sumTime = 0;
int n = 1;
for (int i = 0; i < 10; i++) {
try {
ByteSour... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public byte[] getBlock(int blockStart, int blockLength) throws IOException
{
// We include a separate check for int overflow.
if ((blockStart < 0)
|| (blockLength < 0)
|| (blockStart + blockLength < 0)
... | #fixed code
public byte[] getBlock(int blockStart, int blockLength) throws IOException
{
// We include a separate check for int overflow.
if ((blockStart < 0)
|| (blockLength < 0)
|| (blockStart + blockLength < 0)
|| (bl... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public byte[] getBlock(final long start, final int length) throws IOException {
RandomAccessFile raf = null;
boolean canThrow = false;
try {
raf = new RandomAccessFile(file, "r");
// We include a separate c... | #fixed code
@Override
public byte[] getBlock(final long start, final int length) throws IOException {
try (RandomAccessFile raf = new RandomAccessFile(file, "r")) {
// We include a separate check for int overflow.
if ((start < 0) || (length < 0) || (st... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testAddIptcData() throws Exception {
final ByteSource byteSource = new ByteSourceFile(imageFile);
final Map<String, Object> params = new HashMap<String, Object>();
final boolean ignoreImageData = isPhilHarveyTestImage(image... | #fixed code
@Test
public void testAddIptcData() throws Exception {
final ByteSource byteSource = new ByteSourceFile(imageFile);
final Map<String, Object> params = new HashMap<String, Object>();
final boolean ignoreImageData = isPhilHarveyTestImage(imageFile);... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected File createTempFile(final byte src[]) throws IOException {
final File file = createTempFile("raw_", ".bin");
// write test bytes to file.
OutputStream os = null;
boolean canThrow = false;
try {
os = new File... | #fixed code
protected File createTempFile(final byte src[]) throws IOException {
final File file = createTempFile("raw_", ".bin");
// write test bytes to file.
try (FileOutputStream fos = new FileOutputStream(file);
OutputStream os = new BufferedO... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected static ICC_Profile getICCProfile(ByteSource byteSource, Map params)
throws ImageReadException, IOException {
byte bytes[] = getICCProfileBytes(byteSource, params);
if (bytes == null)
return null;
IccProfileParser parser = new IccProfileParser();
Ic... | #fixed code
protected static ICC_Profile getICCProfile(ByteSource byteSource, Map params)
throws ImageReadException, IOException {
byte bytes[] = getICCProfileBytes(byteSource, params);
if (bytes == null)
return null;
IccProfileParser parser = new IccProfileParser();
IccProfi... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void setData(final byte[] bytes) throws IOException {
data = bytes;
BinaryInputStream bis = null;
boolean canThrow = false;
try {
bis = new BinaryInputStream(new ByteArrayInputStream(
bytes), ByteOrder.... | #fixed code
public void setData(final byte[] bytes) throws IOException {
data = bytes;
InputStream bis = null;
boolean canThrow = false;
try {
bis = new ByteArrayInputStream(bytes);
dataTypeSignature = BinaryFunctions.read4Bytes("d... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void writeImage(BufferedImage src, OutputStream os, Map params)
throws ImageWriteException, IOException {
// make copy of params; we'll clear keys as we consume them.
params = (params == null) ? new HashMap() : new HashMa... | #fixed code
@Override
public void writeImage(BufferedImage src, OutputStream os, Map params)
throws ImageWriteException, IOException {
// make copy of params; we'll clear keys as we consume them.
params = (params == null) ? new HashMap() : new HashMap(para... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public byte[] getBlock(int blockStart, int blockLength) throws IOException
{
// We include a separate check for int overflow.
if ((blockStart < 0)
|| (blockLength < 0)
|| (blockStart + blockLength < 0)
... | #fixed code
public byte[] getBlock(int blockStart, int blockLength) throws IOException
{
// We include a separate check for int overflow.
if ((blockStart < 0)
|| (blockLength < 0)
|| (blockStart + blockLength < 0)
|| (bl... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void interpretTile(final ImageBuilder imageBuilder, final byte[] bytes,
final int startX, final int startY, final int xLimit, final int yLimit) throws ImageReadException, IOException {
// changes introduced May 2012
// The following b... | #fixed code
private void interpretTile(final ImageBuilder imageBuilder, final byte[] bytes,
final int startX, final int startY, final int xLimit, final int yLimit) throws ImageReadException, IOException {
// changes introduced May 2012
// The following block o... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static byte[] decompressModifiedHuffman(final byte[] compressed,
final int width, final int height) throws ImageReadException {
final BitInputStreamFlexible inputStream = new BitInputStreamFlexible(
new ByteArrayInputStream(com... | #fixed code
public static byte[] decompressModifiedHuffman(final byte[] compressed,
final int width, final int height) throws ImageReadException {
try (ByteArrayInputStream baos = new ByteArrayInputStream(compressed);
BitInputStreamFlexible inputStream... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void setExifGPSTag(final File jpegImageFile, final File dst) throws IOException,
ImageReadException, ImageWriteException {
OutputStream os = null;
boolean canThrow = false;
try {
TiffOutputSet outputSet = null;
... | #fixed code
public void setExifGPSTag(final File jpegImageFile, final File dst) throws IOException,
ImageReadException, ImageWriteException {
try (FileOutputStream fos = new FileOutputStream(dst);
OutputStream os = new BufferedOutputStream(fos)) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected List<IptcBlock> parseAllBlocks(final byte[] bytes, final boolean verbose,
final boolean strict) throws ImageReadException, IOException {
final List<IptcBlock> blocks = new ArrayList<IptcBlock>();
BinaryInputStream bis = null;
... | #fixed code
protected List<IptcBlock> parseAllBlocks(final byte[] bytes, final boolean verbose,
final boolean strict) throws ImageReadException, IOException {
final List<IptcBlock> blocks = new ArrayList<IptcBlock>();
InputStream bis = null;
boolean c... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testRemove() throws Exception {
final ByteSource byteSource = new ByteSourceFile(imageFile);
final Map<String, Object> params = new HashMap<String, Object>();
final boolean ignoreImageData = isPhilHarveyTestImage(imageFile)... | #fixed code
@Test
public void testRemove() throws Exception {
final ByteSource byteSource = new ByteSourceFile(imageFile);
final Map<String, Object> params = new HashMap<String, Object>();
final boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void dump()
{
dump(new PrintWriter(new OutputStreamWriter(System.out)));
}
#location 3
#vulnerability type RESOURCE_LEAK | #fixed code
public void dump()
{
PrintWriter pw = new PrintWriter(System.out);
dump(pw);
pw.flush();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void writeImage(final BufferedImage src, final File file,
final ImageFormat format, final Map<String, Object> params) throws ImageWriteException,
IOException {
OutputStream os = null;
boolean canThrow = false;
... | #fixed code
public static void writeImage(final BufferedImage src, final File file,
final ImageFormat format, final Map<String, Object> params) throws ImageWriteException,
IOException {
try (FileOutputStream fos = new FileOutputStream(file);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static byte[] decompressT4_1D(final byte[] compressed, final int width,
final int height, final boolean hasFill) throws ImageReadException {
final BitInputStreamFlexible inputStream = new BitInputStreamFlexible(new ByteArrayInputStream(compres... | #fixed code
public static byte[] decompressT4_1D(final byte[] compressed, final int width,
final int height, final boolean hasFill) throws ImageReadException {
final BitInputStreamFlexible inputStream = new BitInputStreamFlexible(new ByteArrayInputStream(compressed));... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void changeSelection(int row, int column, boolean toggle, boolean extend) {
// For shift+click
lastRow = currentRow;
lastColumn = currentColumn;
currentRow = row;
currentColumn = column;
super.changeS... | #fixed code
@Override
public void changeSelection(int row, int column, boolean toggle, boolean extend) {
// For shift+click
lastRow = currentRow;
int lastColumn = currentColumn;
currentRow = row;
currentColumn = column;
super.changeSel... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void performAction() {
AbstractFile targetFile = mainFrame.getActiveTable().getSelectedFile();
if (targetFile == null) {
targetFile = mainFrame.getInactiveTable().getFileTableModel().getFileAt(0).getParent();
}
... | #fixed code
@Override
public void performAction() {
AbstractFile targetFile = mainFrame.getActiveTable().getSelectedFile();
if (targetFile == null) {
targetFile = mainFrame.getActiveTable().getFileTableModel().getFileAt(0).getParent();
}
Ab... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void performAction() {
AbstractFile targetFile = mainFrame.getActiveTable().getSelectedFile();
if (targetFile == null) {
targetFile = mainFrame.getInactiveTable().getFileTableModel().getFileAt(0).getParent();
}
... | #fixed code
@Override
public void performAction() {
AbstractFile targetFile = mainFrame.getActiveTable().getSelectedFile();
if (targetFile == null) {
targetFile = mainFrame.getActiveTable().getFileTableModel().getFileAt(0).getParent();
}
Ab... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void shouldHandleExceptionDuringRequestCreation() throws URISyntaxException, IOException {
exception.expect(IOException.class);
exception.expectMessage("Could not create request");
final AsyncClientHttpRequestFactory factory = ... | #fixed code
@Test
public void shouldHandleExceptionDuringRequestCreation() throws URISyntaxException, IOException {
exception.expect(IOException.class);
exception.expectMessage("Could not create request");
final AsyncClientHttpRequestFactory factory = (uri, ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public String getType() {
return ElementUtils.contains(getRoot(), "name").getTextTrim();
}
#location 2
#vulnerability type NULL_DEREFERENCE | #fixed code
public String getType() {
return ElementUtils.contains(getRoot(), "type").getTextTrim();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testPublishDeleteShapeZip() throws FileNotFoundException, IOException {
if (!enabled()) {
return;
}
// Assume.assumeTrue(enabled);
String ns = "it.geosolutions";
String storeName = "resttestshp";
St... | #fixed code
public void testPublishDeleteShapeZip() throws FileNotFoundException, IOException {
if (!enabled()) {
return;
}
// Assume.assumeTrue(enabled);
deleteAllWorkspaces();
assertTrue(publisher.createWorkspace(DEFAULT_WS));
// ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Before
public void setup() throws Exception {
String ws = "topp";
String storeName = "testshpcollection";
// Delete all resources except styles
deleteAllWorkspacesRecursively();
// Create workspace
... | #fixed code
@Before
public void setup() throws Exception {
if (enabled()){
init();
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testCreateDeletePostGISDatastore() {
if (!enabled()) {
return;
}
String wsName = "it.geosolutions";
String datastoreName = "resttestpostgis";
String description = "description";
String dsNamespace ... | #fixed code
public void testCreateDeletePostGISDatastore() {
if (!enabled()) {
return;
}
deleteAll();
String wsName = DEFAULT_WS;
String datastoreName = "resttestpostgis";
String description = "description";
Str... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void deleteAllLayerGroups() {
List<String> groups = reader.getLayerGroups().getNames();
LOGGER.info("Found " + groups.size() + " layerGroups");
for (String groupName : groups) {
RESTLayerGroup group = reader.getLayerGroup(grou... | #fixed code
private void deleteAllLayerGroups() {
List<String> groups = reader.getLayerGroups().getNames();
LOGGER.info("Found " + groups.size() + " layerGroups");
for (String groupName : groups) {
RESTLayerGroup group = reader.getLayerGroup(groupName)... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public List<String> getWorkspaceNames() {
RESTWorkspaceList list = getWorkspaces();
List<String> names = new ArrayList<String>(list.size());
for (RESTWorkspaceList.RESTShortWorkspace item : list) {
names.add(item.getName());
}... | #fixed code
public List<String> getWorkspaceNames() {
RESTWorkspaceList list = getWorkspaces();
if(list==null){
return Collections.emptyList();
}
List<String> names = new ArrayList<String>(list.size());
for (RESTWorkspaceList.RESTShortWork... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private GSImageMosaicEncoder copyParameters(String wsName, String coverageStoreName,
String csname) throws NumberFormatException {
// get current config for the coverage to extract the params we want to set again
final RESTCoverage coverage =... | #fixed code
private GSImageMosaicEncoder copyParameters(String wsName, String coverageStoreName,
String csname) throws NumberFormatException {
// get current config for the coverage to extract the params we want to set again
final RESTCoverage coverage = reade... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean configureCoverage(final GSCoverageEncoder ce, final String wsname,
final String csname) {
final String cname = ce.getName();
if (cname == null) {
if (LOGGER.isErrorEnabled())
LOGGER.error("Unable to ... | #fixed code
public boolean configureCoverage(final GSCoverageEncoder ce, final String wsname,
final String csname) {
return configureCoverage(ce, wsname, csname, ce.getName());
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void deleteStylesForWorkspace(String workspace) {
RESTStyleList styles = styleManager.getStyles(workspace);
for (NameLinkElem nameLinkElem : styles) {
removeStyleInWorkspace(workspace, nameLinkElem.getName(), true);
}
}
... | #fixed code
private void deleteStylesForWorkspace(String workspace) {
RESTStyleList styles = styleManager.getStyles(workspace);
if (styles==null)
return;
for (NameLinkElem nameLinkElem : styles) {
removeStyleInWorkspace(workspace, nameLinkE... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Before
public void setup() throws Exception {
String ws = "topp";
String storeName = "testshpcollection";
// Delete all resources except styles
deleteAllWorkspacesRecursively();
// Create workspace
... | #fixed code
@Before
public void setup() throws Exception {
if (enabled()){
init();
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void fixDimensions(String wsName, String coverageStoreName, String csname) {
// get current config for the coverage to extract the params we want to set again
final RESTCoverage coverage = reader.getCoverage(wsName, coverageStoreName, csname);
... | #fixed code
private void fixDimensions(String wsName, String coverageStoreName, String csname) {
final GSImageMosaicEncoder coverageEncoder = copyParameters(wsName, coverageStoreName,
csname);
// activate time dimension
final GSD... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testCreateDeletePostGISDatastore() {
if (!enabled()) {
return;
}
String wsName = "it.geosolutions";
String datastoreName = "resttestpostgis";
String description = "description";
String dsNamespace ... | #fixed code
public void testCreateDeletePostGISDatastore() {
if (!enabled()) {
return;
}
deleteAll();
String wsName = DEFAULT_WS;
String datastoreName = "resttestpostgis";
String description = "description";
Str... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void failRequestLimitExceeded(Operation request) {
// Add a header indicating retry should be attempted after some interval.
// Currently set to just one second, subject to change in the future
request.addResponseHeader(Operation.RETRY_AFTER_HEAD... | #fixed code
ScheduledExecutorService getScheduledExecutor() {
return this.scheduledExecutor;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void stop() {
this.channelPool.stop();
if (this.sslChannelPool != null) {
this.sslChannelPool.stop();
}
if (this.http2ChannelPool != null) {
this.http2ChannelPool.stop();
}
this... | #fixed code
@Override
public void stop() {
this.channelPool.stop();
if (this.sslChannelPool != null) {
this.sslChannelPool.stop();
}
if (this.http2ChannelPool != null) {
this.http2ChannelPool.stop();
}
// In prac... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void paginatedbroadcastQueryTasksOnExampleStates () throws Throwable {
VerificationHost targetHost = this.host.getPeerHost();
URI exampleFactoryURI = UriUtils.buildUri(targetHost, ExampleFactoryService.SELF_LINK);
int serviceCount = 100... | #fixed code
private void paginatedbroadcastQueryTasksOnExampleStates () throws Throwable {
VerificationHost targetHost = this.host.getPeerHost();
int serviceCount = 100;
int resultLimit = 30;
QuerySpecification q = new QuerySpecification();
Quer... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void stop() {
this.channelPool.stop();
if (this.sslChannelPool != null) {
this.sslChannelPool.stop();
}
if (this.http2ChannelPool != null) {
this.http2ChannelPool.stop();
}
this... | #fixed code
@Override
public void stop() {
this.channelPool.stop();
if (this.sslChannelPool != null) {
this.sslChannelPool.stop();
}
if (this.http2ChannelPool != null) {
this.http2ChannelPool.stop();
}
// In prac... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private Map<String, LoaderServiceInfo> discoverServices(File libDir,
Map<String, LoaderServiceInfo> existingPackages) {
logFine("Checking for updates in " + libDir.toURI());
Map<String, LoaderServiceInfo> discoveredPackages = new HashMap<Stri... | #fixed code
private Map<String, LoaderServiceInfo> discoverServices(File libDir,
Map<String, LoaderServiceInfo> existingPackages) {
logFine("Checking for updates in " + libDir.toURI());
Map<String, LoaderServiceInfo> discoveredPackages = new HashMap<String, Lo... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void stop() {
this.channelPool.stop();
if (this.sslChannelPool != null) {
this.sslChannelPool.stop();
}
if (this.http2ChannelPool != null) {
this.http2ChannelPool.stop();
}
this... | #fixed code
@Override
public void stop() {
this.channelPool.stop();
if (this.sslChannelPool != null) {
this.sslChannelPool.stop();
}
if (this.http2ChannelPool != null) {
this.http2ChannelPool.stop();
}
// In prac... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void handleRestore(Operation op, RestoreRequest req) {
IndexWriter w = this.writer;
if (w == null) {
op.fail(new CancellationException());
return;
}
// We already have a slot in the semaphore. Acquire the... | #fixed code
private void handleRestore(Operation op, RestoreRequest req) {
IndexWriter w = this.writer;
if (w == null) {
op.fail(new CancellationException());
return;
}
// We already have a slot in the semaphore. Acquire the rest.... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void stop() {
this.channelPool.stop();
if (this.sslChannelPool != null) {
this.sslChannelPool.stop();
}
if (this.http2ChannelPool != null) {
this.http2ChannelPool.stop();
}
this... | #fixed code
@Override
public void stop() {
this.channelPool.stop();
if (this.sslChannelPool != null) {
this.sslChannelPool.stop();
}
if (this.http2ChannelPool != null) {
this.http2ChannelPool.stop();
}
// In prac... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void stop() {
this.channelPool.stop();
if (this.sslChannelPool != null) {
this.sslChannelPool.stop();
}
if (this.http2ChannelPool != null) {
this.http2ChannelPool.stop();
}
this... | #fixed code
@Override
public void stop() {
this.channelPool.stop();
if (this.sslChannelPool != null) {
this.sslChannelPool.stop();
}
if (this.http2ChannelPool != null) {
this.http2ChannelPool.stop();
}
// In prac... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
void startOrSynchService(Operation post, Service child) {
Service s = findService(post.getUri().getPath());
if (s == null) {
startService(post, child);
return;
}
Operation synchPut = Operation.createPut(post.getUr... | #fixed code
ScheduledExecutorService getScheduledExecutor() {
return this.scheduledExecutor;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Autowired(type = PandaTypes.TYPES_LABEL)
@AutowiredParameters(skip = 3, value = {
@Type(with = Src.class, value = "return"),
@Type(with = Src.class, value = "name"),
@Type(with = Src.class, value = "*parameters")
})
boole... | #fixed code
@Autowired(type = PandaTypes.TYPES_LABEL)
@AutowiredParameters(skip = 3, value = {
@Type(with = Src.class, value = "return"),
@Type(with = Src.class, value = "name"),
@Type(with = Src.class, value = "*parameters")
})
boolean par... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testTokenPattern() {
TokenPattern pattern = TokenPattern.builder()
.compile("(method|hidden|local) [static] <return-type> <name>(<parameters>) \\{ <body> \\}[;]")
.build();
LexicalPatternElement cont... | #fixed code
@Test
public void testTokenPattern() {
TokenPattern pattern = TokenPattern.builder()
.compile("(method|hidden|local) [static] <return-type> <name>(<parameters>) \\{ <body> \\}[;]")
.build();
LexicalPatternElement content = ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public NamedExecutable parse(Atom atom) {
final String source = atom.getSourceCode();
final StringBuilder importBuilder = new StringBuilder();
int stage = 0;
Import importElement = null;
String operator = null;
... | #fixed code
@Override
public NamedExecutable parse(Atom atom) {
final String source = atom.getSourcesDivider().getLine();
final StringBuilder importBuilder = new StringBuilder();
int stage = 0;
Import importElement = null;
String operator = nu... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Expression parse(ParserInfo info, TokenizedSource expressionSource) {
if (expressionSource.size() == 1) {
Token token = expressionSource.getToken(0);
String value = token.getTokenValue();
if (token.getType() == TokenTy... | #fixed code
public Expression parse(ParserInfo info, TokenizedSource expressionSource) {
if (expressionSource.size() == 1) {
Token token = expressionSource.getToken(0);
String value = token.getTokenValue();
if (token.getType() == TokenType.LIT... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public Essence run(Particle particle) {
while (parameters[0].getValue(PBoolean.class).isTrue()) {
Essence o = super.run(particle);
if (o != null) {
return o;
}
}
return null;
}... | #fixed code
@Override
public Essence run(Particle particle) {
while (factors[0].getValue(PBoolean.class).isTrue()) {
Essence o = super.run(particle);
if (o != null) {
return o;
}
}
return null;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean isPublic(Object o) {
int accessFlags = o instanceof ClassFile ?
((ClassFile) o).getAccessFlags() :
o instanceof FieldInfo ? ((FieldInfo) o).getAccessFlags() :
o instanceof MethodInfo ? ((Meth... | #fixed code
public boolean isPublic(Object o) {
if (o == null) {
return false;
}
if (o instanceof ClassFile) {
return AccessFlag.isPublic(((ClassFile) o).getAccessFlags());
}
if (o instanceof MethodInfo) {
retu... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public boolean extract(TokenizedSource tokenizedSource) {
TokenPatternUnit[] units = pattern.getUnits();
ArrayDistributor<TokenPatternUnit> unitsDistributor = new ArrayDistributor<>(units);
TokenReader tokenReader = new PandaTokenReader(tokenize... | #fixed code
public boolean extract(TokenizedSource tokenizedSource) {
TokenPatternUnit[] units = pattern.getUnits();
ArrayDistributor<TokenPatternUnit> unitsDistributor = new ArrayDistributor<>(units);
TokenReader tokenReader = new PandaTokenReader(tokenizedSourc... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public @Nullable Expression parse(ParserData data, TokenizedSource expressionSource, boolean silence) {
ModuleRegistry registry = data.getComponent(PandaComponents.MODULE_REGISTRY);
if (expressionSource.size() == 1) {
Token token = expressio... | #fixed code
public @Nullable Expression parse(ParserData data, TokenizedSource expressionSource, boolean silence) {
ModuleRegistry registry = data.getComponent(PandaComponents.MODULE_REGISTRY);
if (expressionSource.size() == 1) {
Token token = expressionSourc... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public @Nullable Tokens read(ExpressionParser main, Tokens source) {
Tokens selected = SubparserUtils.readSeparated(main, source, ARRAY_SEPARATORS, SubparserUtils.NAMES_FILTER, MatchableDistributor::hasNext);
MatchableDistributor matchable... | #fixed code
@Override
public @Nullable Tokens read(ExpressionParser main, Tokens source) {
SourceStream stream = new PandaSourceStream(source);
ExpressionSubparsers subparsers = main.getSubparsers().fork();
subparsers.removeSubparser(getName());
Expr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private TokenExtractorResult matchDynamics(List<LexicalPatternElement> elements, TokenizedSource[] dynamics) {
TokenExtractorResult result = new TokenExtractorResult(true);
for (int i = 0; i < elements.size(); i++) {
LexicalPatternElement no... | #fixed code
private TokenExtractorResult matchDynamics(List<LexicalPatternElement> elements, TokenizedSource[] dynamics) {
TokenExtractorResult result = new TokenExtractorResult(true);
for (int i = 0; i < elements.size(); i++) {
LexicalPatternElement nodeElem... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Variable createVariable(ParserData data, ModuleLoader loader, Scope scope, boolean mutable, boolean nullable, String type, String name) {
ClassPrototype prototype = loader.forClass(type).fetch();
if (!StringUtils.isEmpty(type) && prototype == nul... | #fixed code
public Variable createVariable(ParserData data, ModuleLoader loader, Scope scope, boolean mutable, boolean nullable, String type, String name) {
if (StringUtils.isEmpty(type)) {
throw new PandaParserFailure("Type does not specified", data);
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public List<Parameter> parse(ParserData info, @Nullable Tokens tokens) {
if (TokensUtils.isEmpty(tokens)) {
return new ArrayList<>(0);
}
TokenRepresentation[] tokenRepresentations = tokens.toArray();
List<Parameter> parameter... | #fixed code
public List<Parameter> parse(ParserData info, @Nullable Tokens tokens) {
if (TokensUtils.isEmpty(tokens)) {
return new ArrayList<>(0);
}
TokenRepresentation[] tokenRepresentations = tokens.toArray();
List<Parameter> parameters = ne... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected LookupResult extractNode(List<LexicalPatternElement> nextElements, TokenDistributor distributor) {
int skip = 0;
for (LexicalPatternElement nextElement : nextElements) {
if (!nextElement.isWildcard()) {
break;
... | #fixed code
protected LookupResult extractNode(List<LexicalPatternElement> nextElements, TokenDistributor distributor) {
int skip = 0;
for (LexicalPatternElement nextElement : nextElements) {
if (!nextElement.isWildcard()) {
break;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void parse(TokenizedSource source, ParserInfo info) {
PandaScript script = info.getComponent(Components.SCRIPT);
TokenReader reader = new PandaTokenReader(source);
Extractor extractor = PATTERN.extractor();
List<Toke... | #fixed code
@Override
public void parse(TokenizedSource source, ParserInfo info) {
PandaScript script = info.getComponent(Components.SCRIPT);
TokenReader reader = new PandaTokenReader(source);
Extractor extractor = PATTERN.extractor();
List<TokenizedS... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void run() {
CommandLine commandLine = new CommandLine(this);
if (usageHelpRequested) {
CommandLine.usage(this, System.out);
return;
}
if (versionInfoRequested) {
commandLine.prin... | #fixed code
@Override
public void run() {
CommandLine commandLine = new CommandLine(this);
if (usageHelpRequested) {
CommandLine.usage(this, System.out);
return;
}
if (versionInfoRequested) {
commandLine.printVersi... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void parse(@Nullable Tokens source, ParserData data) {
PandaScript script = data.getComponent(PandaComponents.PANDA_SCRIPT);
ModuleLoader registry = script.getModuleLoader();
Expression instance = null;
ClassPrototyp... | #fixed code
@Override
public void parse(@Nullable Tokens source, ParserData data) {
PandaScript script = data.getComponent(PandaComponents.PANDA_SCRIPT);
ModuleLoader registry = script.getModuleLoader();
Expression instance = null;
ClassPrototype prot... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public InterceptorData handle(UnifiedBootstrapParser parser, ParserData data) {
InterceptorData interceptorData = new InterceptorData();
if (pattern != null) {
TokenExtractorResult result = pattern.extract(null);
}
... | #fixed code
@Override
public InterceptorData handle(UnifiedBootstrapParser parser, ParserData data) {
InterceptorData interceptorData = new InterceptorData();
if (pattern != null) {
TokenExtractorResult result = pattern.extract(data.getComponent(Universal... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@SafeVarargs
@SuppressWarnings("unchecked")
public static <T> T[] mergeArrays(T[]... arrays) {
int size = 0;
Class<?> type = null;
for (T[] array : arrays) {
size += array.length;
type = array.getClass().getCompon... | #fixed code
@SafeVarargs
@SuppressWarnings("unchecked")
public static <T> T[] mergeArrays(T[]... arrays) {
if (isEmpty(arrays)) {
throw new IllegalArgumentException("Merge arrays requires at least one array as argument");
}
return mergeArrays(... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Autowired
public void parse(ParserData data, LocalData localData) {
if (localData == null || data.getComponent(PandaComponents.CONTAINER) == null) {
System.out.println("xxx");
}
localData.allocateInstance(data.getComponent(Panda... | #fixed code
@Autowired
public void parse(ParserData data, LocalData localData) {
localData.allocateInstance(data.getComponent(PandaComponents.CONTAINER).reserveCell());
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public PrototypeMethod generate(ModuleRegistry registry) {
ClassPrototype returnType = PandaModuleRegistryAssistant.forClass(registry, method.getReturnType());
ClassPrototype[] parametersTypes = PandaClassPrototypeUtils.toTypes(registry, method.getParame... | #fixed code
public PrototypeMethod generate(ModuleRegistry registry) {
ClassPrototype returnType = PandaModuleRegistryAssistant.forClass(registry, method.getReturnType());
ClassPrototype[] parametersTypes = PandaClassPrototypeUtils.toTypes(registry, method.getParameterTyp... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
void getURLContent() {
String urlContent = IOUtils.getURLContent("https://panda-lang.org/");
Assertions.assertNotNull(urlContent);
Assertions.assertTrue(urlContent.contains("<html"));
}
#location 5
... | #fixed code
@Test
void getURLContent() {
Result<String, IOException> result = IOUtils.fetchContent("https://panda-lang.org/");
assertTrue(result.isDefined());
assertNotNull(result.getValue());
assertTrue(result.getValue().contains("<html"));
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Expression parse(ParserData data, SourceStream source, ExpressionParserSettings settings) {
ExpressionContext context = new ExpressionContext(this, data, source);
ExpressionParserWorker worker = new ExpressionParserWorker(this, context, source, su... | #fixed code
public Expression parse(ParserData data, SourceStream source, ExpressionParserSettings settings) {
return parse(data, source, settings, null);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public ClassPrototype generate(Class<?> type) {
Module module = ModuleRegistry.getDefault().getOrCreate(type.getPackage().getName());
ClassPrototype prototype = new ClassPrototype(module, type.getSimpleName());
prototype.getAssociated().add(type... | #fixed code
public ClassPrototype generate(Class<?> type) {
Module module = ModuleRegistry.getDefault().getOrCreate(type.getPackage().getName());
ClassPrototype prototype = module.get(type.getSimpleName());
if (prototype != null) {
return prototype;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public PandaMethodBuilder parameterTypes(ModuleLoader moduleLoader, String... parameterTypes) {
ClassPrototype[] prototypes = new ClassPrototype[parameterTypes.length];
for (int i = 0; i < prototypes.length; i++) {
prototypes[i] = moduleLoad... | #fixed code
public PandaMethodBuilder parameterTypes(ModuleLoader moduleLoader, String... parameterTypes) {
ClassPrototypeReference[] prototypes = new ClassPrototypeReference[parameterTypes.length];
for (int i = 0; i < prototypes.length; i++) {
prototypes[i] ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testTokenPattern() {
TokenPattern pattern = TokenPattern.builder()
.compile("(method|hidden|local) [static] <return-type> <name> `(<*parameters>`) `{ <*body> `}[;]")
.build();
LexicalPatternElement c... | #fixed code
@Test
public void testTokenPattern() {
TokenPattern pattern = TokenPattern.builder()
.compile("class <name> [extends <inherited>] `{ <*body> `}")
.build();
LexicalPatternElement content = pattern.getPatternContent();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void prepare() {
AbyssExtractorOpposites opposites = new AbyssExtractorOpposites();
for (int i = 0; i < tokenizedSource.size(); i++) {
TokenRepresentation representation = tokenizedSource.get(i);
Token token = representat... | #fixed code
private void prepare() {
AbyssExtractorOpposites opposites = new AbyssExtractorOpposites();
for (int i = 0; i < tokenizedSource.size(); i++) {
TokenRepresentation representation = tokenizedSource.get(i);
if (representation == null) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static ArrayClassPrototype obtain(ModuleLoader loader, String type) {
ClassPrototype prototype = loader.forClass(type.replace(PandaArray.IDENTIFIER, StringUtils.EMPTY));
if (prototype == null) {
return null;
}
int dim... | #fixed code
public static ArrayClassPrototype obtain(ModuleLoader loader, String type) {
ArrayClassPrototype cached = ARRAY_PROTOTYPES.get(type);
if (cached != null) {
return cached;
}
ClassPrototype prototype = loader.forClass(type.replace(P... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void parse(Tokens source, ParserData data) {
PandaScript script = data.getComponent(PandaComponents.PANDA_SCRIPT);
TokenReader reader = new PandaTokenReader(source);
GappedPatternExtractor extractor = PATTERN.extractor();
... | #fixed code
@Override
public void parse(Tokens source, ParserData data) {
PandaScript script = data.getComponent(PandaComponents.PANDA_SCRIPT);
TokenReader reader = new PandaTokenReader(source);
GappedPatternExtractor extractor = PATTERN.extractor();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public NamedExecutable parse(Atom atom) {
final String source = atom.getSourceCode();
final StringBuilder groupBuilder = new StringBuilder();
boolean nsFlag = false;
for (char c : source.toCharArray()) {
if (Cha... | #fixed code
@Override
public NamedExecutable parse(Atom atom) {
final String source = atom.getSourcesDivider().getLine();
final StringBuilder groupBuilder = new StringBuilder();
boolean nsFlag = false;
for (char c : source.toCharArray()) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static Type getArrayOf(Module module, Referencable baseReferencable, int dimensions) {
Reference baseReference = baseReferencable.toReference();
Class<?> componentType = ArrayUtils.getDimensionalArrayType(baseReference.getAssociatedClass().fetchIm... | #fixed code
public static Type getArrayOf(Module module, Referencable baseReferencable, int dimensions) {
Reference baseReference = baseReferencable.toReference();
Class<?> componentType = ArrayUtils.getDimensionalArrayType(baseReference.getAssociatedClass().fetchImplemen... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void assumeDocker() throws Exception {
Launcher.LocalLauncher localLauncher = new Launcher.LocalLauncher(StreamTaskListener.NULL);
try {
Assume.assumeThat("Docker working", localLauncher.launch().cmds(DockerTool.getExecutable(nu... | #fixed code
public static void assumeDocker() throws Exception {
assumeDocker(new VersionNumber(DEFAULT_MINIMUM_VERSION));
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void extractConfigurationParameters() {
super.extractConfigurationParameters();
// Load configuration parameters.
configColor = ChatColor.getByChar(mainConfig.getString("Color", "5"));
configIcon = StringEscapeUtils.unescapeJava(mainConfig.getStr... | #fixed code
@Override
public void extractConfigurationParameters() {
super.extractConfigurationParameters();
// Load configuration parameters.
configColor = ChatColor.getByChar(mainConfig.getString("Color", "5"));
configIcon = mainConfig.getString("Icon", "\u2618");
configAdditi... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void saveConfig(String configString, File file) throws IOException {
String configuration = this.prepareConfigString(configString);
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
writer.write(configur... | #fixed code
public void saveConfig(String configString, File file) throws IOException {
String configuration = this.prepareConfigString(configString);
BufferedWriter writer = null;
try {
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private boolean isButtonClicked(InventoryClickEvent event, ItemStack button) {
if (event.getCurrentItem().isSimilar(button)) {
// Clicked item seems to be the button. But player could have clicked on item in his personal inventory that
// matches the properties of ... | #fixed code
private boolean isButtonClicked(InventoryClickEvent event, ItemStack button) {
if (event.getCurrentItem() != null && event.getCurrentItem().isSimilar(button)) {
// Clicked item seems to be the button. But player could have clicked on item in his personal inventory that
/... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Reader getConfigContent(File file) throws IOException {
if (!file.exists())
return null;
int commentNum = 0;
String addLine;
String currentLine;
StringBuilder whole = new StringBuilder("");
BufferedReader reader = new BufferedReader(new InputStream... | #fixed code
public Reader getConfigContent(File file) throws IOException {
if (!file.exists())
return null;
int commentNum = 0;
String addLine;
String currentLine;
StringBuilder whole = new StringBuilder("");
BufferedReader reader = null;
try {
reader = new BufferedRe... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryClick(InventoryClickEvent event) {
if (event.getInventory().getType() != InventoryType.BREWING || event.getAction() == InventoryAction.NOTHING
|| event.getClick() == Click... | #fixed code
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryClick(InventoryClickEvent event) {
ItemStack item = event.getCurrentItem();
if (event.getInventory().getType() != InventoryType.BREWING || event.getAction() == InventoryAction.NOT... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void copyResource(InputStream resource, File file) throws IOException {
OutputStream out = new FileOutputStream(file);
int length;
byte[] buf = new byte[1024];
while ((length = resource.read(buf)) > 0)
out.write(buf, 0, length);
out.close();
reso... | #fixed code
private void copyResource(InputStream resource, File file) throws IOException {
OutputStream out = null;
try {
out = new FileOutputStream(file);
int length;
byte[] buf = new byte[1024];
while ((length = resource.read(buf)) > 0)
out.write(buf, 0, length);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public List<String> getRewardListing(String path, Player player) {
List<String> rewardTypes = new ArrayList<>();
Set<String> keyNames = mainConfig.getKeys(true);
if (economy != null && keyNames.contains(path + ".Money")) {
int amount = getRewardAmount(path, "Mone... | #fixed code
public List<String> getRewardListing(String path, Player player) {
List<String> rewardTypes = new ArrayList<>();
Set<String> keyNames = mainConfig.getKeys(true);
if (economy != null && keyNames.contains(path + ".Money")) {
int amount = getRewardAmount(path, "Money");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void parseDisabledCategories() throws PluginLoadError {
extractDisabledCategoriesFromConfig();
// Need PetMaster with a minimum version of 1.4 for PetMasterGive and PetMasterReceive categories.
if ((!disabledCategories.contains(NormalAchievements.PETMASTERGIV... | #fixed code
private void parseDisabledCategories() throws PluginLoadError {
extractDisabledCategoriesFromConfig();
// Need PetMaster with a minimum version of 1.4 for PetMasterGive and PetMasterReceive categories.
if ((!disabledCategories.contains(NormalAchievements.PETMASTERGIVE)
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void extractConfigurationParameters() {
configHideNotReceivedCategories = mainConfig.getBoolean("HideNotReceivedCategories");
configHideNoPermissionCategories = mainConfig.getBoolean("HideNoPermissionCategories");
langListGUITitle = ChatColor.trans... | #fixed code
@Override
public void extractConfigurationParameters() {
configHideNotReceivedCategories = mainConfig.getBoolean("HideNotReceivedCategories");
configHideNoPermissionCategories = mainConfig.getBoolean("HideNoPermissionCategories");
langListGUITitle = ChatColor.translateAl... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onInventoryClick(InventoryClickEvent event) {
Inventory inventory = event.getInventory();
if (!(inventory.getHolder() instanceof AchievementInventoryHolder) || event.getRawSlot() < 0) {
... | #fixed code
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onInventoryClick(InventoryClickEvent event) {
Inventory inventory = event.getInventory();
if (!(inventory.getHolder() instanceof AchievementInventoryHolder) || event.getRawSlot() < 0) {
retu... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private String rewardItem(Player player, ItemStack item) {
if (player.getInventory().firstEmpty() != -1) {
player.getInventory().addItem(item);
} else {
player.getWorld().dropItem(player.getLocation(), item);
}
String name = item.getItemMeta().getDisplayName... | #fixed code
private String rewardItem(Player player, ItemStack item) {
if (player.getInventory().firstEmpty() != -1) {
player.getInventory().addItem(item);
} else {
player.getWorld().dropItem(player.getLocation(), item);
}
ItemMeta itemMeta = item.getItemMeta();
String name ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private int getCommentsAmount(File file) throws IOException {
if (!file.exists())
return 0;
int comments = 0;
String currentLine;
BufferedReader reader = new BufferedReader(new FileReader(file));
while ((currentLine = reader.readLine()) != null)
if (curr... | #fixed code
private int getCommentsAmount(File file) throws IOException {
if (!file.exists())
return 0;
int comments = 0;
String currentLine;
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(file));
while ((currentLine = reader.readLine()) ... | Below is the vulnerable code, please generate the patch based on the following information. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.