input stringlengths 205 73.3k | output stringlengths 64 73.2k | instruction stringclasses 1
value |
|---|---|---|
#vulnerable code
public void testSimpleObjectWrite()
throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createJsonGenerator(sw);
gen.writeStartObject();
gen.writeFieldName("first");
gen.write... | #fixed code
public void testSimpleObjectWrite()
throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createGenerator(sw);
gen.writeStartObject();
gen.writeFieldName("first");
gen.writeNumber(-90... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testSimpleArrayWrite()
throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createJsonGenerator(sw);
gen.writeStartArray();
gen.writeNumber(13);
gen.writeBoolean(tr... | #fixed code
public void testSimpleArrayWrite()
throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createGenerator(sw);
gen.writeStartArray();
gen.writeNumber(13);
gen.writeBoolean(true);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Deprecated
protected JsonParser _createJsonParser(Reader r, IOContext ctxt) throws IOException, JsonParseException {
return new ReaderBasedJsonParser(ctxt, _parserFeatures, r, _objectCodec,
_rootCharSymbols.makeChild(isEnabled(JsonFactory.Fe... | #fixed code
@Deprecated
protected JsonParser _createJsonParser(Reader r, IOContext ctxt) throws IOException, JsonParseException {
return _createParser(r, ctxt);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Deprecated
protected JsonGenerator _createUTF8JsonGenerator(OutputStream out, IOContext ctxt)
throws IOException
{
UTF8JsonGenerator gen = new UTF8JsonGenerator(ctxt,
_generatorFeatures, _objectCodec, out);
if (_character... | #fixed code
@Deprecated
protected JsonGenerator _createUTF8JsonGenerator(OutputStream out, IOContext ctxt)
throws IOException
{
return _createUTF8Generator(out, ctxt);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static Version versionFor(Class<?> cls)
{
InputStream in;
Version version = null;
try {
in = cls.getResourceAsStream(VERSION_FILE);
if (in != null) {
try {
BufferedReader br ... | #fixed code
public static Version versionFor(Class<?> cls)
{
final InputStream in = cls.getResourceAsStream(VERSION_FILE);
if (in == null)
return Version.unknownVersion();
try {
InputStreamReader reader = new InputStreamReader(in, "UT... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testInvalidArrayWrite()
throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createJsonGenerator(sw);
gen.writeStartArray();
// Mismatch:
try {
gen.writ... | #fixed code
public void testInvalidArrayWrite()
throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createGenerator(sw);
gen.writeStartArray();
// Mismatch:
try {
gen.writeEndObject... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected String _generateRoot(JsonFactory jf, PrettyPrinter pp) throws IOException
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createJsonGenerator(sw);
gen.setPrettyPrinter(pp);
gen.writeStartObject(... | #fixed code
protected String _generateRoot(JsonFactory jf, PrettyPrinter pp) throws IOException
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createGenerator(sw);
gen.setPrettyPrinter(pp);
gen.writeStartObject();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testArrayCount() throws Exception
{
final String EXP = "[6,[1,2,9(3)](2)]";
final JsonFactory jf = new JsonFactory();
for (int i = 0; i < 2; ++i) {
boolean useBytes = (i > 0);
ByteArrayOutputStrea... | #fixed code
public void testArrayCount() throws Exception
{
final String EXP = "[6,[1,2,9(3)](2)]";
final JsonFactory jf = new JsonFactory();
for (int i = 0; i < 2; ++i) {
boolean useBytes = (i > 0);
ByteArrayOutputStream byte... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Deprecated
protected JsonGenerator _createJsonGenerator(Writer out, IOContext ctxt)
throws IOException
{
WriterBasedJsonGenerator gen = new WriterBasedJsonGenerator(ctxt,
_generatorFeatures, _objectCodec, out);
if (_chara... | #fixed code
@Deprecated
protected JsonGenerator _createJsonGenerator(Writer out, IOContext ctxt)
throws IOException
{
/* NOTE: MUST call the deprecated method until it is deleted, just so
* that override still works as expected, for now.
*/
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testWriteLongCustomEscapes() throws Exception
{
JsonFactory jf = new JsonFactory();
jf.setCharacterEscapes(ESC_627); // must set to trigger bug
StringBuilder longString = new StringBuilder();
while (longString.length() < 2... | #fixed code
public void testWriteLongCustomEscapes() throws Exception
{
JsonFactory jf = new JsonFactory();
jf.setCharacterEscapes(ESC_627); // must set to trigger bug
StringBuilder longString = new StringBuilder();
while (longString.length() < 2000) {... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testRaw() throws IOException
{
JsonFactory jf = new JsonFactory();
StringWriter sw = new StringWriter();
JsonGenerator gen = jf.createJsonGenerator(sw);
gen.writeStartArray();
gen.writeRaw("-123, true");
ge... | #fixed code
public void testRaw() throws IOException
{
JsonFactory jf = new JsonFactory();
StringWriter sw = new StringWriter();
JsonGenerator gen = jf.createGenerator(sw);
gen.writeStartArray();
gen.writeRaw("-123, true");
gen.writeRaw... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void doTestBasicEscaping(boolean charArray)
throws Exception
{
for (int i = 0; i < SAMPLES.length; ++i) {
String VALUE = SAMPLES[i];
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory... | #fixed code
private void doTestBasicEscaping(boolean charArray)
throws Exception
{
for (int i = 0; i < SAMPLES.length; ++i) {
String VALUE = SAMPLES[i];
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().cre... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testAutoFlushOrNot() throws Exception
{
JsonFactory f = new JsonFactory();
assertTrue(f.isEnabled(JsonGenerator.Feature.FLUSH_PASSED_TO_STREAM));
MyChars sw = new MyChars();
JsonGenerator jg = f.createJsonGenerator(sw);
... | #fixed code
public void testAutoFlushOrNot() throws Exception
{
JsonFactory f = new JsonFactory();
assertTrue(f.isEnabled(JsonGenerator.Feature.FLUSH_PASSED_TO_STREAM));
MyChars sw = new MyChars();
JsonGenerator jg = f.createGenerator(sw);
jg.w... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testFieldValueWrites()
throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createJsonGenerator(sw);
gen.writeStartObject();
gen.writeNumberField("long", 3L);
... | #fixed code
public void testFieldValueWrites()
throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createGenerator(sw);
gen.writeStartObject();
gen.writeNumberField("long", 3L);
gen.writ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testConvenienceMethods()
throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createJsonGenerator(sw);
gen.writeStartObject();
final BigDecimal dec = new BigDecimal("0.1")... | #fixed code
public void testConvenienceMethods()
throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createGenerator(sw);
gen.writeStartObject();
final BigDecimal dec = new BigDecimal("0.1");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testCopyObjectTokens()
throws IOException
{
JsonFactory jf = new JsonFactory();
final String DOC = "{ \"a\":1, \"b\":[{ \"c\" : null }] }";
JsonParser jp = jf.createJsonParser(new StringReader(DOC));
StringWriter s... | #fixed code
public void testCopyObjectTokens()
throws IOException
{
JsonFactory jf = new JsonFactory();
final String DOC = "{ \"a\":1, \"b\":[{ \"c\" : null }] }";
JsonParser jp = jf.createParser(new StringReader(DOC));
StringWriter sw = new St... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@SuppressWarnings("resource")
private void _testEscapeAboveAscii(boolean useStream) throws Exception
{
JsonFactory f = new JsonFactory();
final String VALUE = "chars: [\u00A0]/[\u1234]";
final String KEY = "fun:\u0088:\u3456";
Byt... | #fixed code
@SuppressWarnings("resource")
private void _testEscapeAboveAscii(boolean useStream) throws Exception
{
JsonFactory f = new JsonFactory();
final String VALUE = "chars: [\u00A0]/[\u1234]";
final String KEY = "fun:\u0088:\u3456";
ByteArray... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private String _writeNumbers(JsonFactory jf) throws IOException
{
StringWriter sw = new StringWriter();
JsonGenerator jg = jf.createJsonGenerator(sw);
jg.writeStartArray();
jg.writeNumber(1);
jg.writeNumber(2L);
j... | #fixed code
private String _writeNumbers(JsonFactory jf) throws IOException
{
StringWriter sw = new StringWriter();
JsonGenerator jg = jf.createGenerator(sw);
jg.writeStartArray();
jg.writeNumber(1);
jg.writeNumber(2L);
jg.writeNum... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testInvalidObjectWrite()
throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createJsonGenerator(sw);
gen.writeStartObject();
// Mismatch:
try {
gen.wr... | #fixed code
public void testInvalidObjectWrite()
throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createGenerator(sw);
gen.writeStartObject();
// Mismatch:
try {
gen.writeEndArra... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testCopyRootTokens()
throws IOException
{
JsonFactory jf = new JsonFactory();
final String DOC = "\"text\\non two lines\" true false 2.0";
JsonParser jp = jf.createJsonParser(new StringReader(DOC));
StringWriter sw... | #fixed code
public void testCopyRootTokens()
throws IOException
{
JsonFactory jf = new JsonFactory();
final String DOC = "\"text\\non two lines\" true false 2.0";
JsonParser jp = jf.createParser(new StringReader(DOC));
StringWriter sw = new Str... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void _testNonNumericQuoting(JsonFactory jf, boolean quoted)
throws IOException
{
StringWriter sw = new StringWriter();
JsonGenerator jg = jf.createJsonGenerator(sw);
jg.writeStartObject();
jg.writeFieldName("double");
... | #fixed code
private void _testNonNumericQuoting(JsonFactory jf, boolean quoted)
throws IOException
{
StringWriter sw = new StringWriter();
JsonGenerator jg = jf.createGenerator(sw);
jg.writeStartObject();
jg.writeFieldName("double");
jg... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testIsClosed()
throws IOException
{
JsonFactory jf = new JsonFactory();
for (int i = 0; i < 2; ++i) {
boolean stream = ((i & 1) == 0);
JsonGenerator jg = stream ?
jf.createJsonGenerator(new ... | #fixed code
public void testIsClosed()
throws IOException
{
JsonFactory jf = new JsonFactory();
for (int i = 0; i < 2; ++i) {
boolean stream = ((i & 1) == 0);
JsonGenerator jg = stream ?
jf.createGenerator(new StringWrit... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testLongText() throws Exception
{
final int LEN = 96000;
StringBuilder sb = new StringBuilder(LEN + 100);
Random r = new Random(99);
while (sb.length() < LEN) {
sb.append(r.nextInt());
sb.append(" x... | #fixed code
public void testLongText() throws Exception
{
final int LEN = 96000;
StringBuilder sb = new StringBuilder(LEN + 100);
Random r = new Random(99);
while (sb.length() < LEN) {
sb.append(r.nextInt());
sb.append(" xyz foo... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testObjectCount() throws Exception
{
final String EXP = "{\"x\":{\"a\":1,\"b\":2(2)}(1)}";
final JsonFactory jf = new JsonFactory();
for (int i = 0; i < 2; ++i) {
boolean useBytes = (i > 0);
ByteArrayOutpu... | #fixed code
public void testObjectCount() throws Exception
{
final String EXP = "{\"x\":{\"a\":1,\"b\":2(2)}(1)}";
final JsonFactory jf = new JsonFactory();
for (int i = 0; i < 2; ++i) {
boolean useBytes = (i > 0);
ByteArrayOutputStrea... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testConfigDefaults() throws IOException
{
JsonFactory jf = new JsonFactory();
JsonGenerator jg = jf.createJsonGenerator(new StringWriter());
assertFalse(jg.isEnabled(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS));
}
... | #fixed code
public void testConfigDefaults() throws IOException
{
JsonFactory jf = new JsonFactory();
JsonGenerator jg = jf.createGenerator(new StringWriter());
assertFalse(jg.isEnabled(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS));
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void _testStreaming(boolean useBytes) throws IOException
{
final int[] SIZES = new int[] {
1, 2, 3, 4, 5, 6,
7, 8, 12,
100, 350, 1900, 6000, 19000, 65000,
139000
};
JsonFactory jsonFact... | #fixed code
private void _testStreaming(boolean useBytes) throws IOException
{
final int[] SIZES = new int[] {
1, 2, 3, 4, 5, 6,
7, 8, 12,
100, 350, 1900, 6000, 19000, 65000,
139000
};
JsonFactory jsonFactory = ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testLongerObjects() throws Exception
{
JsonFactory jf = new JsonFactory();
for (int i = 0; i < 2; ++i) {
boolean useChars = (i == 0);
JsonGenerator jgen;
ByteArrayOutputStream bout = new ByteArrayOutput... | #fixed code
public void testLongerObjects() throws Exception
{
JsonFactory jf = new JsonFactory();
for (int i = 0; i < 2; ++i) {
boolean useChars = (i == 0);
JsonGenerator jgen;
ByteArrayOutputStream bout = new ByteArrayOutputStream... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testCopyArrayTokens()
throws IOException
{
JsonFactory jf = new JsonFactory();
final String DOC = "123 [ 1, null, [ false ] ]";
JsonParser jp = jf.createJsonParser(new StringReader(DOC));
StringWriter sw = new Stri... | #fixed code
public void testCopyArrayTokens()
throws IOException
{
JsonFactory jf = new JsonFactory();
final String DOC = "123 [ 1, null, [ false ] ]";
JsonParser jp = jf.createParser(new StringReader(DOC));
StringWriter sw = new StringWriter()... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void _testEscapeCustom(boolean useStream) throws Exception
{
JsonFactory f = new JsonFactory().setCharacterEscapes(new MyEscapes());
final String STR_IN = "[abcd/"+((char) TWO_BYTE_ESCAPED)+"/"+((char) THREE_BYTE_ESCAPED)+"]";
final S... | #fixed code
private void _testEscapeCustom(boolean useStream) throws Exception
{
JsonFactory f = new JsonFactory().setCharacterEscapes(new MyEscapes());
final String STR_IN = "[abcd/"+((char) TWO_BYTE_ESCAPED)+"/"+((char) THREE_BYTE_ESCAPED)+"]";
final String ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void _testSurrogates(JsonFactory f, boolean checkText) throws IOException
{
byte[] json = "{\"text\":\"\uD83D\uDE03\"}".getBytes("UTF-8");
// first
JsonParser jp = f.createJsonParser(json);
assertToken(JsonToken.START_OBJECT, ... | #fixed code
private void _testSurrogates(JsonFactory f, boolean checkText) throws IOException
{
byte[] json = "{\"text\":\"\uD83D\uDE03\"}".getBytes("UTF-8");
// first
JsonParser jp = f.createParser(json);
assertToken(JsonToken.START_OBJECT, jp.nextTok... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testRawValue() throws IOException
{
JsonFactory jf = new JsonFactory();
StringWriter sw = new StringWriter();
JsonGenerator gen = jf.createJsonGenerator(sw);
gen.writeStartArray();
gen.writeRawValue("7");
g... | #fixed code
public void testRawValue() throws IOException
{
JsonFactory jf = new JsonFactory();
StringWriter sw = new StringWriter();
JsonGenerator gen = jf.createGenerator(sw);
gen.writeStartArray();
gen.writeRawValue("7");
gen.writeRa... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testConvenienceMethodsWithNulls()
throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createJsonGenerator(sw);
gen.writeStartObject();
gen.writeStringField("str", null);
... | #fixed code
public void testConvenienceMethodsWithNulls()
throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createGenerator(sw);
gen.writeStartObject();
gen.writeStringField("str", null);
ge... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static Version versionFor(Class<?> cls)
{
InputStream in;
Version version = null;
try {
in = cls.getResourceAsStream(VERSION_FILE);
if (in != null) {
try {
BufferedReader br ... | #fixed code
public static Version versionFor(Class<?> cls)
{
final InputStream in = cls.getResourceAsStream(VERSION_FILE);
if (in == null)
return Version.unknownVersion();
try {
InputStreamReader reader = new InputStreamReader(in, "UT... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void _testFieldNameQuoting(JsonFactory jf, boolean quoted)
throws IOException
{
StringWriter sw = new StringWriter();
JsonGenerator jg = jf.createJsonGenerator(sw);
jg.writeStartObject();
jg.writeFieldName("foo");
... | #fixed code
private void _testFieldNameQuoting(JsonFactory jf, boolean quoted)
throws IOException
{
StringWriter sw = new StringWriter();
JsonGenerator jg = jf.createGenerator(sw);
jg.writeStartObject();
jg.writeFieldName("foo");
jg.wri... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void updateGC() {
if (perfDataSupport) {
ygcCount.update((Long) ygcCountCounter.getValue());
ygcTimeMills.update(perfData.tickToMills(ygcTimeCounter));
fullgcCount.update((Long) fullGcCountCounter.getValue());
fullgcTimeMills.update(perfData.tickToMil... | #fixed code
private void updateGC() {
if (perfDataSupport) {
ygcCount.update((Long) ygcCountCounter.getValue());
ygcTimeMills.update(perfData.tickToMills(ygcTimeCounter));
fullgcCount.update((Long) fullGcCountCounter.getValue());
fullgcTimeMills.update(perfData.tickToMills(ful... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void run() {
log.info("ProactiveGcTask starting, oldGenOccupancyFraction:" + oldGenOccupancyFraction + ", datetime: "
+ new Date());
try {
oldMemoryPool = getOldMemoryPool();
long maxOldBytes = getMemoryPoolMaxOrCommitted(oldMemoryPool);
long oldUse... | #fixed code
public void run() {
logger.info("ProactiveGcTask starting, oldGenOccupancyFraction:" + oldGenOccupancyFraction);
try {
long usedOldBytes = logOldGenStatus();
if (needTriggerGc(maxOldBytes, usedOldBytes, oldGenOccupancyFraction)) {
preGc();
doGc();
postGc()... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void init() throws IOException {
try {
perfData = PerfData.connect(Integer.parseInt(pid));
perfDataSupport = true;
} catch (Exception e) {
System.err.println("PerfData not support");
}
vmArgs = Utils.join(jmxClient.getRuntimeMXBean().getInputArgum... | #fixed code
private void init() throws IOException {
try {
perfData = PerfData.connect(Integer.parseInt(pid));
perfDataSupport = true;
} catch (Exception e) {
System.err.println("PerfData not support");
}
if (perfDataSupport) {
vmArgs = (String) perfData.findCounter("ja... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void run() {
while (true) {
try {
String command = new BufferedReader(new InputStreamReader(System.in)).readLine().trim();
if (command.equals("t")) {
vjtop.setNeedForFurtherInput(true);
System.err.print(" Input TID for stack:");
String pi... | #fixed code
public void run() {
while (true) {
try {
String command = reader.readLine().trim().toLowerCase();
if (command.equals("t")) {
printStacktrace();
} else if (command.equals("d")) {
changeDisplayMode();
} else if (command.equals("q")) {
app.exit()... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void updateGC() {
if (perfDataSupport) {
ygcCount.update((Long) ygcCountCounter.getValue());
ygcTimeMills.update(perfData.tickToMills(ygcTimeCounter));
fullgcCount.update((Long) fullGcCountCounter.getValue());
fullgcTimeMills.update(perfData.tickToMil... | #fixed code
private void updateGC() {
if (perfDataSupport) {
ygcCount.update((Long) ygcCountCounter.getValue());
ygcTimeMills.update(perfData.tickToMills(ygcTimeCounter));
fullgcCount.update((Long) fullGcCountCounter.getValue());
fullgcTimeMills.update(perfData.tickToMills(ful... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void updateMemoryPool() throws IOException {
MemoryPoolMXBean survivorMemoryPool = jmxClient.getMemoryPoolManager().getSurvivorMemoryPool();
if (survivorMemoryPool != null) {
surUsedBytes = survivorMemoryPool.getUsage().getUsed();
surMaxBytes = getMemoryP... | #fixed code
private void updateMemoryPool() throws IOException {
JmxMemoryPoolManager memoryPoolManager = jmxClient.getMemoryPoolManager();
edenUsedBytes = memoryPoolManager.getEdenMemoryPool().getUsage().getUsed();
edenMaxBytes = getMemoryPoolMaxOrCommited(memoryPoolManager.getEdenM... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void printHelp() throws Exception {
tty.println(" t [tid]: print stack trace for the thread you choose");
tty.println(" a : list all thread's id and name");
tty.println(" m : change threads display mode and ordering");
tty.println(" i : change flush interva... | #fixed code
private void printHelp() throws Exception {
tty.println(" t [tid]: print stack trace for the thread you choose");
tty.println(" a : list all thread's id and name");
tty.println(" m : change threads display mode and ordering");
tty.println(" i [num]: change flush interval... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void init() throws IOException {
Map<String, Counter> perfCounters = null;
try {
perfData = PerfData.connect(Integer.parseInt(pid));
perfCounters = perfData.getCounters();
initPerfCounters(perfCounters);
perfDataSupport = true;
} catch (Throwable ... | #fixed code
private void init() throws IOException {
Map<String, Counter> perfCounters = null;
try {
perfData = PerfData.connect(Integer.parseInt(pid));
perfCounters = perfData.getAllCounters();
initPerfCounters(perfCounters);
perfDataSupport = true;
} catch (Throwable ign... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void updateGC() {
if (perfDataSupport) {
ygcCount.update(ygcCountCounter.longValue());
ygcTimeMills.update(perfData.tickToMills(ygcTimeCounter));
if (fullGcCountCounter != null) {
fullgcCount.update(fullGcCountCounter.longValue());
fullgcTimeMill... | #fixed code
private void updateGC() {
if (perfDataSupport) {
ygcCount.update(ygcCountCounter.longValue());
ygcTimeMills.update(perfData.tickToMills(ygcTimeCounter));
if (fullGcCountCounter != null) {
fullgcCount.update(fullGcCountCounter.longValue());
fullgcTimeMills.upda... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) {
try {
// 1. create option parser
OptionParser parser = createOptionParser();
OptionSet optionSet = parser.parse(args);
if (optionSet.has("help")) {
printHelper(parser);
System.exit(0);
}
// 2. create v... | #fixed code
public static void main(String[] args) {
try {
// 1. create option parser
OptionParser parser = createOptionParser();
OptionSet optionSet = parser.parse(args);
if (optionSet.has("help")) {
printHelper(parser);
System.exit(0);
}
// 2. create vminfo
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void changeDisplayMode() {
app.preventFlush();
String mode = readLine(
" Input number of Display Mode(1.cpu, 2.syscpu 3.total cpu 4.total syscpu 5.memory 6.total memory, current "
+ app.view.threadInfoMode + "): ");
ThreadInfoMode detailMode = Thre... | #fixed code
private void changeDisplayMode() {
app.preventFlush();
String mode = readLine(" Input Display Mode(cpu, syscpu, totalcpu, totalsyscpu, memory, totalmemory, current "
+ app.view.threadInfoMode + "): ");
ThreadInfoMode detailMode = ThreadInfoMode.valueOf(mode);
if (de... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Double getFGCT() throws Exception {
return Double.parseDouble(getAttribute(fgcCollector, COLLECTION_TIME_ATTRIBUTE).toString()) / 1000;
}
#location 2
#vulnerability type NULL_DEREFERENCE | #fixed code
public Double getFGCT() throws Exception {
if (fgcCollector == null) {
return 0.0;
}
return Double.parseDouble(getAttribute(fgcCollector, COLLECTION_TIME_ATTRIBUTE).toString()) / 1000;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void updateMemoryPool() throws IOException {
JmxMemoryPoolManager memoryPoolManager = jmxClient.getMemoryPoolManager();
eden = new Usage(memoryPoolManager.getEdenMemoryPool().getUsage());
old = new Usage(memoryPoolManager.getOldMemoryPool().getUsage());
wa... | #fixed code
private void updateMemoryPool() throws IOException {
JmxMemoryPoolManager memoryPoolManager = jmxClient.getMemoryPoolManager();
eden = new Usage(memoryPoolManager.getEdenMemoryPool().getUsage());
old = new Usage(memoryPoolManager.getOldMemoryPool().getUsage());
warning.... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void run() {
while (true) {
try {
String command = readLine();
handleCommand(command);
if (!app.view.shouldExit()) {
tty.print(" Input command (h for help):");
}
} catch (Exception e) {
e.printStackTrace(tty);
}
}
} ... | #fixed code
@Override
public void run() {
// background执行时,console为Null
if (console == null) {
return;
}
while (true) {
try {
String command = readLine("");
if (command == null) {
break;
}
handleCommand(command);
if (!app.view.shouldExit()) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void updateMemoryPool() {
if (!isJmxStateOk()) {
return;
}
try {
JmxMemoryPoolManager memoryPoolManager = jmxClient.getMemoryPoolManager();
eden = new Usage(memoryPoolManager.getEdenMemoryPool().getUsage());
old = new Usage(memoryPoolManager.getO... | #fixed code
private void updateMemoryPool() {
if (!isJmxStateOk()) {
return;
}
try {
JmxMemoryPoolManager memoryPoolManager = jmxClient.getMemoryPoolManager();
MemoryPoolMXBean edenMXBean = memoryPoolManager.getEdenMemoryPool();
if (edenMXBean != null) {
eden = new U... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private static void clearTerminal() {
if (System.getProperty("os.name").contains("Windows")) {
// hack
System.out.printf("%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n");
} else if (System.getProperty("vjtop.altClear") != null) {
System.out.pr... | #fixed code
private static void clearTerminal() {
if (Utils.isWindows) {
System.out.printf("%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n");
} else {
System.out.print(CLEAR_TERMINAL_ANSI_CMD);
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void run() {
while (true) {
try {
String command = new BufferedReader(new InputStreamReader(System.in)).readLine().trim();
if (command.equals("t")) {
vjtop.setNeedForFurtherInput(true);
System.err.print(" Input TID for stack:");
String pi... | #fixed code
public void run() {
while (true) {
try {
String command = reader.readLine().trim().toLowerCase();
if (command.equals("t")) {
printStacktrace();
} else if (command.equals("d")) {
changeDisplayMode();
} else if (command.equals("q")) {
app.exit()... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws Exception {
String path = "E:/btdata/bt_cumulation.txt";
BufferedReader br = new BufferedReader(new FileReader(path));
String line = null;
br.readLine();
PrintWriter pw = new PrintWri... | #fixed code
public static void main(String[] args) throws Exception {
BitSet bitSet = new BitSet(Integer.MAX_VALUE);//hashcode的值域
String url = "http://baidu.com/a";
int hashcode = url.hashCode() & 0x7FFFFFFF;
bitSet.set(hashcode);
System.out.prin... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) {
new ClassPathXmlApplicationContext("spring/rocketmq-consumer.xml");
}
#location 2
#vulnerability type RESOURCE_LEAK | #fixed code
public static void main(String[] args) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/rocketmq-consumer.xml");
context.registerShutdownHook();
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void process(Socket socket) {
SocketInputStream input = null;
OutputStream output = null;
try {
input = new SocketInputStream(socket.getInputStream(), 2048); // 1.读取套接字的输入流
output = socket.getOutputStream();
... | #fixed code
public void process(Socket socket) {
SocketInputStream input = null;
OutputStream output = null;
try {
input = new SocketInputStream(socket.getInputStream(), 2048); // 1.读取套接字的输入流
output = socket.getOutputStream();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"META-INF/spring/dubbo-demo-consumer.xml"});
context.start();
// dubbo protocol
DemoService demoService = (DemoService) context.getBe... | #fixed code
public static void main(String[] args) throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"META-INF/spring/dubbo-demo-consumer.xml"});
context.start();
// 异步调用
async(context);
// dubbo protocol
DemoService d... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws Exception {
String path = "E:/btdata/bt_cumulation.txt";
BufferedReader br = new BufferedReader(new FileReader(path));
String line = null;
br.readLine();
PrintWriter pw = new PrintWri... | #fixed code
public static void main(String[] args) throws Exception {
BitSet bitSet = new BitSet(Integer.MAX_VALUE);//hashcode的值域
String url = "http://baidu.com/a";
int hashcode = url.hashCode() & 0x7FFFFFFF;
bitSet.set(hashcode);
System.out.prin... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Vector4fc toImmutable() {
if (Proxy.DISABLE_PROXIES)
return this;
if (proxy != null)
return proxy;
synchronized (this) {
if (proxy != null)
return proxy;
proxy = Proxy.createV... | #fixed code
public Vector4fc toImmutable() {
if (Proxy.DISABLE_PROXIES)
return this;
return Proxy.createVector4fc(this);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Quaternionfc toImmutable() {
if (Proxy.DISABLE_PROXIES)
return this;
if (proxy != null)
return proxy;
synchronized (this) {
if (proxy != null)
return proxy;
proxy = Proxy.crea... | #fixed code
public Quaternionfc toImmutable() {
if (Proxy.DISABLE_PROXIES)
return this;
return Proxy.createQuaternionfc(this);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Vector3fc toImmutable() {
if (Proxy.DISABLE_PROXIES)
return this;
if (proxy != null)
return proxy;
synchronized (this) {
if (proxy != null)
return proxy;
proxy = Proxy.createV... | #fixed code
public Vector3fc toImmutable() {
if (Proxy.DISABLE_PROXIES)
return this;
return Proxy.createVector3fc(this);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
long start = System.currentTimeMillis();
REQUEST_START_TIME.set(start);
String url = WebTools.getHomeUrl(request);
... | #fixed code
@Override
public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
long start = System.currentTimeMillis();
REQUEST_START_TIME.set(start);
String url = WebTools.getHomeUrl(request);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
long start = System.currentTimeMillis();
REQUEST_START_TIME.set(start);
String url = WebTools.getHomeUrl(request);
... | #fixed code
@Override
public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
long start = System.currentTimeMillis();
REQUEST_START_TIME.set(start);
String url = WebTools.getHomeUrl(request);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void executeTask(IConversationMemory memory) {
IData<String> expressionsData = memory.getCurrentStep().getLatestData(EXPRESSIONS_PARSED_IDENTIFIER);
List<IData<Context>> contextDataList = memory.getCurrentStep().getAllData(CONTEXT_ID... | #fixed code
@Override
public void executeTask(IConversationMemory memory) {
IData<String> expressionsData = memory.getCurrentStep().getLatestData(EXPRESSIONS_PARSED_IDENTIFIER);
List<IData<Context>> contextDataList = memory.getCurrentStep().getAllData(CONTEXT_IDENTIFI... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void serializeToJsonIteratorWithEmbeddedMap() throws Exception {
final Graph g = new TinkerGraph();
final Vertex v = g.addVertex();
final Map<String, Object> map = new HashMap<>();
map.put("x", 500);
map.put("y", ... | #fixed code
@Test
public void serializeToJsonIteratorWithEmbeddedMap() throws Exception {
Graph g = TinkerGraph.open(null);
final Vertex v = g.addVertex();
final Map<String, Object> map = new HashMap<>();
map.put("x", 500);
map.put("y", "some")... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testGremlinOLAP() throws Exception {
Graph g = TinkerFactory.createClassic();
ComputeResult result =
g.compute().program(GremlinVertexProgram.create().gremlin(() -> (Gremlin)
//Gremlin.of().ou... | #fixed code
@Test
public void testGremlinOLAP() throws Exception {
Graph g = TinkerFactory.createClassic();
ComputeResult result =
g.compute().program(GremlinVertexProgram.create().gremlin(() -> (Gremlin)
//Gremlin.of().out("cre... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testTinkerGraph() {
TinkerGraph g = new TinkerGraph();
g.createIndex("name", Vertex.class);
Vertex marko = g.addVertex(TinkerProperty.make("name", "marko", "age", 33));
Vertex stephen = g.addVertex(TinkerProperty.make("name", ... | #fixed code
public void testTinkerGraph() {
TinkerGraph g = new TinkerGraph();
g.createIndex("name", Vertex.class);
Vertex marko = g.addVertex(TinkerProperty.make("name", "marko", "age", 33, "blah", "bloop"));
Vertex stephen = g.addVertex(TinkerProperty.ma... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void serializeToJsonIteratorWithEmbeddedMap() throws Exception {
Graph g = TinkerGraph.open(Optional.empty());
final Vertex v = g.addVertex();
final Map<String, Object> map = new HashMap<>();
map.put("x", 500);
ma... | #fixed code
@Test
public void serializeToJsonIteratorWithEmbeddedMap() throws Exception {
final Graph g = TinkerGraph.open();
final Vertex v = g.addVertex();
final Map<String, Object> map = new HashMap<>();
map.put("x", 500);
map.put("y", "some... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private FunctionThatThrows<RequestMessage, Object> select(final RequestMessage message, final GremlinServer.Graphs graphs) {
final Bindings bindings = new SimpleBindings();
bindings.putAll(extractBindingsFromMessage(message));
if (message.option... | #fixed code
private FunctionThatThrows<RequestMessage, Object> select(final RequestMessage message, final GremlinServer.Graphs graphs) {
final Bindings bindings = new SimpleBindings();
bindings.putAll(extractBindingsFromMessage(message));
final String language = ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public TableEvaluationRequest readFrom(Class<TableEvaluationRequest> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException {
String charset = getCharset(m... | #fixed code
@Override
public TableEvaluationRequest readFrom(Class<TableEvaluationRequest> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException {
String charset = getCharset(mediaTy... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
static
private boolean checkFormat(BufferedReader reader, CsvPreference format) throws IOException {
CsvListReader parser = new CsvListReader(reader, format);
int columns = 0;
// Check the header line and the first ten lines
for(int line = 0; line < (1 + 10); li... | #fixed code
static
private boolean checkFormat(BufferedReader reader, CsvPreference format) throws IOException {
CsvListReader parser = new CsvListReader(reader, format);
int columns = 0;
// Check the header line and the first ten lines
for(int line = 0; line < (1 + 10); line++){... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
static
private boolean checkFormat(BufferedReader reader, CsvPreference format) throws IOException {
CsvListReader parser = new CsvListReader(reader, format);
int columns = 0;
// Check the header line and the first ten lines
for(int line = 0; line < (1 + 10); li... | #fixed code
static
private boolean checkFormat(BufferedReader reader, CsvPreference format) throws IOException {
CsvListReader parser = new CsvListReader(reader, format){
@Override
public void close(){
}
};
int columns = 0;
// Check the header line and the first ten lin... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void premain(final String args, final Instrumentation instrumentation) {
Map<String, String> argMap = parseArgs(args);
String statsdServer = argMap.get("server");
int statsdPort = Integer.valueOf(argMap.get("port"));
String ... | #fixed code
public static void premain(final String args, final Instrumentation instrumentation) {
Arguments arguments = Arguments.parseArgs(args);
String statsdServer = arguments.statsdServer;
int statsdPort = arguments.statsdPort;
String prefix = argumen... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private List<String> readContractList() {
return ResourceLoader
.getBufferedReader(getClass(), SLA_CONTRACTS_LIST)
.lines()
.filter(l -> !l.startsWith("#"))
.filter(l -> !l.trim().isEmpty())
.collect(to... | #fixed code
private List<String> readContractList() {
return ResourceLoader
.newBufferedReader(SLA_CONTRACTS_LIST, getClass())
.lines()
.filter(l -> !l.startsWith("#"))
.filter(l -> !l.trim().isEmpty())
.collect(toList()... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void addLink(final long srcId, final long destId, final double bandwidth, final double latency) {
if (getTopologycalGraph() == null) {
graph = new TopologicalGraph();
}
if (map == null) {
map = new Ha... | #fixed code
@Override
public void addLink(final long srcId, final long destId, final double bandwidth, final double latency) {
if (getTopologycalGraph() == null) {
graph = new TopologicalGraph();
}
if (entitiesMap == null) {
entitiesMa... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void onUpdateCloudletProcessingListener(CloudletVmEventInfo eventInfo) {
Cloudlet c = eventInfo.getCloudlet();
double cpuUsage = c.getUtilizationModelCpu().getUtilization(eventInfo.getTime())*100;
double ramUsage = c.getUtilizationModelRa... | #fixed code
private void onUpdateCloudletProcessingListener(CloudletVmEventInfo eventInfo) {
Cloudlet c = eventInfo.getCloudlet();
double cpuUsage = c.getUtilizationModelCpu().getUtilization(eventInfo.getTime())*100;
double ramUsage = c.getUtilizationModelRam().ge... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected void updateExecutionTask(ResCloudlet rcl, double currentTime, Processor p) {
NetworkCloudlet netcl = (NetworkCloudlet)rcl.getCloudlet();
/**
* @todo @author manoelcampos updates the execution
* length of the task, considering ... | #fixed code
protected void updateExecutionTask(ResCloudlet rcl, double currentTime, Processor p) {
NetworkCloudlet netcl = (NetworkCloudlet)rcl.getCloudlet();
if(!(netcl.getCurrentTask() instanceof CloudletExecutionTask))
throw new RuntimeException(
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private List<String> readContractList() {
return ResourceLoader
.getBufferedReader(getClass(), SLA_CONTRACTS_LIST)
.lines()
.filter(l -> !l.startsWith("#"))
.filter(l -> !l.trim().isEmpty())
... | #fixed code
private List<String> readContractList() {
return ResourceLoader
.newBufferedReader(SLA_CONTRACTS_LIST, getClass())
.lines()
.filter(l -> !l.startsWith("#"))
.filter(l -> !l.trim().isEmpty())
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void vmProcessingUpdateListener(VmHostEventInfo info) {
final Vm vm = info.getVm();
//Destroys VM 1 when its CPU usage reaches 90%
if(vm.getCpuPercentUtilization() > 0.9 && vm.isCreated()){
System.out.printf(
"... | #fixed code
private void vmProcessingUpdateListener(VmHostEventInfo info) {
final Vm vm = info.getVm();
//Destroys VM 1 when its CPU usage reaches 90%
if(vm.getCpuPercentUtilization() > 0.9 && vm.isCreated()){
System.out.printf(
"%n# %.... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) {
final CloudletTaskCompletionTimeMinimizationExperiment exp = new CloudletTaskCompletionTimeMinimizationExperiment(344L);
exp.setVerbose(true);
exp.run();
System.out.println();
System.out.pr... | #fixed code
public static void main(String[] args) {
final CloudletTaskCompletionTimeMinimizationExperiment exp = new CloudletTaskCompletionTimeMinimizationExperiment(344L);
exp.setVerbose(true);
exp.run();
System.out.println();
System.out.printf("... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static GoogleTaskEventsTraceReader getInstance(
final CloudSim simulation,
final String filePath,
final Function<TaskEvent, Cloudlet> cloudletCreationFunction)
{
final InputStream reader = ResourceLoader.getInputStream(filePath... | #fixed code
public static GoogleTaskEventsTraceReader getInstance(
final CloudSim simulation,
final String filePath,
final Function<TaskEvent, Cloudlet> cloudletCreationFunction)
{
final InputStream reader = ResourceLoader.newInputStream(filePath, Goog... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private List<String> readContractList() {
return ResourceLoader
.getBufferedReader(getClass(), SLA_CONTRACTS_LIST)
.lines()
.map(String::trim)
.filter(line -> !line.isEmpty())
.filter(line -> !line.star... | #fixed code
private List<String> readContractList() {
return ResourceLoader
.newBufferedReader(SLA_CONTRACTS_LIST, getClass())
.lines()
.map(String::trim)
.filter(line -> !line.isEmpty())
.filter(line -> !line.startsWith... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static SlaContract getInstance(final String jsonFilePath) {
return getInstanceInternal(ResourceLoader.getInputStream(jsonFilePath, SlaContract.class));
}
#location 2
#vulnerability type RESOURC... | #fixed code
public static SlaContract getInstance(final String jsonFilePath) {
return getInstanceInternal(ResourceLoader.newInputStream(jsonFilePath, SlaContract.class));
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void onClockTick(final EventInfo info) {
for (Host host : datacenter0.getHostList()) {
System.out.printf("Host %-2d Time: %.0f\n", host.getId(), info.getTime());
for (Vm vm : host.getVmList()) {
System.out.printf(
... | #fixed code
private void onClockTick(final EventInfo info) {
for (Host host : datacenter0.getHostList()) {
System.out.printf("Host %-2d Time: %.0f%n", host.getId(), info.getTime());
for (Vm vm : host.getVmList()) {
System.out.printf(
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public final Host setActive(final boolean activate) {
if(isFailed() && activate){
throw new IllegalStateException("The Host is failed and cannot be activated.");
}
notifyStartupOrShutdown(activate);
if(activate... | #fixed code
@Override
public final Host setActive(final boolean activate) {
if(isFailed() && activate){
throw new IllegalStateException("The Host is failed and cannot be activated.");
}
final boolean wasActive = this.active;
if(activate &... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static BriteNetworkTopology getInstance(final String fileName){
final InputStreamReader reader = new InputStreamReader(ResourceLoader.getInputStream(fileName, BriteNetworkTopology.class));
return new BriteNetworkTopology(reader);
}
... | #fixed code
public static BriteNetworkTopology getInstance(final String fileName){
final InputStreamReader reader = ResourceLoader.newInputStreamReader(fileName, BriteNetworkTopology.class);
return new BriteNetworkTopology(reader);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static GoogleMachineEventsTraceReader getInstance(
final String filePath,
final Function<MachineEvent, Host> hostCreationFunction)
{
final InputStream reader = ResourceLoader.getInputStream(filePath, GoogleMachineEventsTraceReader.clas... | #fixed code
public static GoogleMachineEventsTraceReader getInstance(
final String filePath,
final Function<MachineEvent, Host> hostCreationFunction)
{
final InputStream reader = ResourceLoader.newInputStream(filePath, GoogleMachineEventsTraceReader.class);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void printVmUtilizationHistory(Vm vm) {
System.out.println(vm + " RAM and BW utilization history");
System.out.println("----------------------------------------------------------------------------------");
//A set containing all resource... | #fixed code
private void printVmUtilizationHistory(Vm vm) {
System.out.println(vm + " RAM and BW utilization history");
System.out.println("----------------------------------------------------------------------------------");
//A set containing all resource utili... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void showCpuUtilizationForAllHosts() {
System.out.println("\nHosts CPU utilization history for the entire simulation period");
int numberOfUsageHistoryEntries = 0;
for (Host host : hostList) {
double mipsByPe = host.getTotalMi... | #fixed code
private void showCpuUtilizationForAllHosts() {
System.out.printf("%nHosts CPU utilization history for the entire simulation period%n");
int numberOfUsageHistoryEntries = 0;
for (Host host : hostList) {
double mipsByPe = host.getTotalMipsCap... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public final Host setActive(final boolean activate) {
if(isFailed() && activate){
throw new IllegalStateException("The Host is failed and cannot be activated.");
}
notifyStartupOrShutdown(activate);
if(activate... | #fixed code
@Override
public final Host setActive(final boolean activate) {
if(isFailed() && activate){
throw new IllegalStateException("The Host is failed and cannot be activated.");
}
final boolean wasActive = this.active;
if(activate &... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static SwfWorkloadFileReader getInstance(final String fileName, final int mips) {
final InputStream reader = ResourceLoader.getInputStream(fileName, SwfWorkloadFileReader.class);
return new SwfWorkloadFileReader(fileName, reader, mips);
}
... | #fixed code
public static SwfWorkloadFileReader getInstance(final String fileName, final int mips) {
final InputStream reader = ResourceLoader.newInputStream(fileName, SwfWorkloadFileReader.class);
return new SwfWorkloadFileReader(fileName, reader, mips);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void showCpuUtilizationForAllVms(final double simulationFinishTime) {
System.out.println("\nHosts CPU utilization history for the entire simulation period\n");
int numberOfUsageHistoryEntries = 0;
for (Vm vm : vmlist) {
System... | #fixed code
private void showCpuUtilizationForAllVms(final double simulationFinishTime) {
System.out.printf("%nHosts CPU utilization history for the entire simulation period%n%n");
int numberOfUsageHistoryEntries = 0;
for (Vm vm : vmlist) {
System.out.... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static GoogleTaskUsageTraceReader getInstance(
final List<DatacenterBroker> brokers,
final String filePath)
{
final InputStream reader = ResourceLoader.getInputStream(filePath, GoogleTaskUsageTraceReader.class);
return new Goog... | #fixed code
public static GoogleTaskUsageTraceReader getInstance(
final List<DatacenterBroker> brokers,
final String filePath)
{
final InputStream reader = ResourceLoader.newInputStream(filePath, GoogleTaskUsageTraceReader.class);
return new GoogleTask... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public final boolean generateFailure() {
final int numberOfFailedPes = setFailedHostPes();
final long hostWorkingPes = host.getNumberOfWorkingPes();
final long vmsRequiredPes = getPesSumOfWorkingVms();
Log.printFormattedLine("\t%.2f: Gene... | #fixed code
public final boolean generateFailure() {
final int numberOfFailedPes = setFailedHostPes();
final long hostWorkingPes = host.getNumberOfWorkingPes();
final long vmsRequiredPes = getPesSumOfWorkingVms();
Log.printFormattedLine("\t%.2f: Generated ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private static Properties loadWithNormalMode(final String propertyFilePath)
throws Exception {
Properties props = new Properties();
props.load(new FileInputStream(propertyFilePath));
return props;
}
#... | #fixed code
private static Properties loadWithNormalMode(final String propertyFilePath)
throws Exception {
Properties props = new Properties();
props.load(new InputStreamReader(new FileInputStream(propertyFilePath), "utf-8"));
return props;
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static WatchMgr getWatchMgr(FetcherMgr fetcherMgr) throws Exception {
if (!ConfigMgr.isInit()) {
throw new Exception(
"ConfigMgr should be init before WatchFactory.getWatchMgr");
}
if (hosts == null) {
... | #fixed code
public static WatchMgr getWatchMgr(FetcherMgr fetcherMgr) throws Exception {
if (!ConfigMgr.isInit()) {
throw new Exception(
"ConfigMgr should be init before WatchFactory.getWatchMgr");
}
if (hosts == null) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public String downloadFromServer(RemoteUrl remoteUrl, String fileName, String localFileDir, String localFileDirTemp,
String copy2TargetDirPath, boolean enableLocalDownloadDirInClassPath,
... | #fixed code
@Override
public String downloadFromServer(RemoteUrl remoteUrl, String fileName, String localFileDir, String localFileDirTemp,
String copy2TargetDirPath, boolean enableLocalDownloadDirInClassPath,
i... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private static Properties loadWithTomcatMode(final String propertyFilePath)
throws Exception {
Properties props = new Properties();
try {
// 先用TOMCAT模式进行导入
// http://blog.csdn.net/minfree/article/details/1800311
... | #fixed code
private static Properties loadWithTomcatMode(final String propertyFilePath)
throws Exception {
Properties props = new Properties();
try {
// 先用TOMCAT模式进行导入
// http://blog.csdn.net/minfree/article/details/1800311
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@ManagedMetric(description = "Total Disk Space assigned")
public long getTotalDiskAssigned() {
return (Long) parseStorageTotals().get("hdd").get("total");
}
#location 3
#vulnerability type NULL_DEREFERENCE | #fixed code
@ManagedMetric(description = "Total Disk Space assigned")
public long getTotalDiskAssigned() {
return convertPotentialLong(parseStorageTotals().get("hdd").get("total"));
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@ManagedMetric(description = "Total Disk Space free")
public long getTotalDiskFree() {
return (Long) parseStorageTotals().get("hdd").get("free");
}
#location 3
#vulnerability type NULL_DEREFERENCE | #fixed code
@ManagedMetric(description = "Total Disk Space free")
public long getTotalDiskFree() {
return convertPotentialLong(parseStorageTotals().get("hdd").get("free"));
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@ManagedMetric(description = "Total RAM assigned")
public long getTotalRAMAssigned() {
return (Long) parseStorageTotals().get("ram").get("total");
}
#location 3
#vulnerability type NULL_DEREFERENCE | #fixed code
@ManagedMetric(description = "Total RAM assigned")
public long getTotalRAMAssigned() {
return convertPotentialLong(parseStorageTotals().get("ram").get("total"));
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@ManagedMetric(description = "Total Disk Space used")
public long getTotalDiskUsed() {
return (Long) parseStorageTotals().get("hdd").get("used");
}
#location 3
#vulnerability type NULL_DEREFERENCE | #fixed code
@ManagedMetric(description = "Total Disk Space used")
public long getTotalDiskUsed() {
return convertPotentialLong(parseStorageTotals().get("hdd").get("used"));
} | 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.