input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#vulnerable code public static ArrayList<String> runNative(String cmdToRun) { Process p = null; try { p = Runtime.getRuntime().exec(cmdToRun); p.waitFor(); } catch (IOException e) { return null; } catch (InterruptedException e) { return null; } BufferedReader reade...
#fixed code public static ArrayList<String> runNative(String cmdToRun) { Process p = null; try { p = Runtime.getRuntime().exec(cmdToRun); //p.waitFor(); } catch (IOException e) { return null; } BufferedReader reader = new BufferedReader(new InputStreamReader( p.getIn...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public double getCpuVoltage() { ArrayList<String> hwInfo = ExecutingCommand.runNative("wmic cpu get CurrentVoltage"); for (String checkLine : hwInfo) { if (checkLine.length() == 0 || checkLine.toLowerCase().contains("currentvolt...
#fixed code @Override public double getCpuVoltage() { // Initialize double volts = 0d; // If we couldn't get through normal WMI go directly to OHM if (this.voltIdentifierStr != null) { double[] vals = wmiGetValuesForKeys("/namespace:\\\\roo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void populateReadWriteMaps() { // Although the field names say "PerSec" this is the Raw Data from which // the associated fields are populated in the Formatted Data class, so // in fact this is the data we want Map<String, List<St...
#fixed code private void populateReadWriteMaps() { // Although the field names say "PerSec" this is the Raw Data from which // the associated fields are populated in the Formatted Data class, so // in fact this is the data we want Map<String, List<Object>>...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean updateAttributes() { try { File ifDir = new File(String.format("/sys/class/net/%s/statistics", getName())); if (!ifDir.isDirectory()) { return false; } } catch (SecurityExce...
#fixed code @Override public boolean updateAttributes() { try { File ifDir = new File(String.format("/sys/class/net/%s/statistics", getName())); if (!ifDir.isDirectory()) { return false; } } catch (SecurityException ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void populateReadWriteMaps() { // Although the field names say "PerSec" this is the Raw Data from which // the associated fields are populated in the Formatted Data class, so // in fact this is the data we want Map<String, List<St...
#fixed code private void populateReadWriteMaps() { // Although the field names say "PerSec" this is the Raw Data from which // the associated fields are populated in the Formatted Data class, so // in fact this is the data we want Map<String, List<Object>>...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public long[] querySystemCpuLoadTicks() { long[] ticks = new long[TickType.values().length]; WinBase.FILETIME lpIdleTime = new WinBase.FILETIME(); WinBase.FILETIME lpKernelTime = new WinBase.FILETIME(); WinBase.FILETIME lpUs...
#fixed code @Override public long[] querySystemCpuLoadTicks() { // To get load in processor group scenario, we need perfmon counters, but the // _Total instance is an average rather than total (scaled) number of ticks // which matches GetSystemTimes() results....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void populatePartitionMaps() { driveToPartitionMap.clear(); partitionToLogicalDriveMap.clear(); partitionMap.clear(); // For Regexp matching DeviceIDs Matcher mAnt; Matcher mDep; // Map drives to partition...
#fixed code private void populatePartitionMaps() { driveToPartitionMap.clear(); partitionToLogicalDriveMap.clear(); partitionMap.clear(); // For Regexp matching DeviceIDs Matcher mAnt; Matcher mDep; // Map drives to partitions ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private List<OSFileStore> getWmiVolumes() { Map<String, List<String>> drives; List<OSFileStore> fs; String volume; long free; long total; fs = new ArrayList<>(); drives = WmiUtil.selectStringsFrom(null, "Win32_Lo...
#fixed code private List<OSFileStore> getWmiVolumes() { Map<String, List<Object>> drives; List<OSFileStore> fs; String volume; long free; long total; fs = new ArrayList<>(); drives = WmiUtil.selectObjectsFrom(null, "Win32_LogicalD...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void removeAllCounters() { // Remove all counter handles for (HANDLEByReference href : counterHandleMap.values()) { PerfDataUtil.removeCounter(href); } counterHandleMap.clear(); // Remove all queries for...
#fixed code public void removeAllCounters() { // Remove all counters from counterHandle map for (HANDLEByReference href : counterHandleMap.values()) { PerfDataUtil.removeCounter(href); } counterHandleMap.clear(); // Remove query ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Processor[] getProcessors() { if (_processors == null) { List<Processor> processors = new ArrayList<Processor>(); Scanner in = null; try { in = new Scanner(new FileReader("/proc/cpuinfo")); } catch (FileNotFoundException e) { System.err.printl...
#fixed code public Processor[] getProcessors() { if (_processors == null) { List<Processor> processors = new ArrayList<Processor>(); List<String> cpuInfo = null; try { cpuInfo = FileUtil.readFile("/proc/cpuinfo"); } catch (IOException e) { System.err.println("Problem ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void populatePartitionMaps() { driveToPartitionMap.clear(); partitionToLogicalDriveMap.clear(); partitionMap.clear(); // For Regexp matching DeviceIDs Matcher mAnt; Matcher mDep; // Map drives to partition...
#fixed code private void populatePartitionMaps() { driveToPartitionMap.clear(); partitionToLogicalDriveMap.clear(); partitionMap.clear(); // For Regexp matching DeviceIDs Matcher mAnt; Matcher mDep; // Map drives to partitions ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public long[] querySystemCpuLoadTicks() { long[] ticks = new long[TickType.values().length]; WinBase.FILETIME lpIdleTime = new WinBase.FILETIME(); WinBase.FILETIME lpKernelTime = new WinBase.FILETIME(); WinBase.FILETIME lpUs...
#fixed code @Override public long[] querySystemCpuLoadTicks() { // To get load in processor group scenario, we need perfmon counters, but the // _Total instance is an average rather than total (scaled) number of ticks // which matches GetSystemTimes() results....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public int[] getFanSpeeds() { int[] fanSpeeds = new int[1]; ArrayList<String> hwInfo = ExecutingCommand .runNative("wmic /namespace:\\\\root\\cimv2 PATH Win32_Fan get DesiredSpeed"); for (String checkLine : hwInfo) {...
#fixed code @Override public int[] getFanSpeeds() { // Initialize int[] fanSpeeds = new int[1]; // If we couldn't get through normal WMI go directly to OHM if (!this.fanSpeedWMI) { double[] vals = wmiGetValuesForKeys("/namespace:\\\\root\\O...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static UsbDevice[] getUsbDevices() { List<UsbDevice> usbDevices = new ArrayList<UsbDevice>(); // Store map of pnpID to name, Manufacturer, serial Map<String, String> nameMap = new HashMap<>(); Map<String, String> vendorMap = new H...
#fixed code public static UsbDevice[] getUsbDevices() { // Start by collecting information for all PNP devices. While in theory // these could be individually queried with a WHERE clause, grabbing // them all up front incurs minimal memory overhead in exchange for...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator, String[] properties, ValueType[] propertyTypes) { if (propertyTypes.length > 1 && properties.length != propertyTypes.length) { throw...
#fixed code private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator, String[] properties, ValueType[] propertyTypes) { if (propertyTypes.length > 1 && properties.length != propertyTypes.length) { throw new I...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public long getSwapUsed() { long total; long available; if (!Kernel32.INSTANCE.GlobalMemoryStatusEx(this._memory)) { LOG.error("Failed to Initialize MemoryStatusEx. Error code: {}", Kernel32.INSTANCE.GetLastErro...
#fixed code @Override public long getSwapUsed() { PdhFmtCounterValue phPagefileCounterValue = new PdhFmtCounterValue(); int ret = Pdh.INSTANCE.PdhGetFormattedCounterValue(pPagefile.getValue(), Pdh.PDH_FMT_LARGE | Pdh.PDH_FMT_1000, null, phPagefileCount...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private List<OSFileStore> getWmiVolumes() { Map<String, List<String>> drives; List<OSFileStore> fs; String volume; long free; long total; fs = new ArrayList<>(); drives = WmiUtil.selectStringsFrom(null, "Win32_Lo...
#fixed code private List<OSFileStore> getWmiVolumes() { Map<String, List<Object>> drives; List<OSFileStore> fs; String volume; long free; long total; fs = new ArrayList<>(); drives = WmiUtil.selectObjectsFrom(null, "Win32_LogicalD...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public HWDiskStore[] getDisks() { List<HWDiskStore> result; result = new ArrayList<>(); Map<String, List<String>> vals = WmiUtil.selectStringsFrom(null, "Win32_DiskDrive", "Name,Manufacturer,Model,SerialNumber,Size"...
#fixed code @Override public HWDiskStore[] getDisks() { List<HWDiskStore> result; result = new ArrayList<>(); readMap.clear(); writeMap.clear(); populateReadWriteMaps(); Map<String, List<Object>> vals = WmiUtil.selectObjectsFrom(null, ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public HWDiskStore[] getDisks() { List<HWDiskStore> result; result = new ArrayList<>(); Map<String, List<String>> vals = WmiUtil.selectStringsFrom(null, "Win32_DiskDrive", "Name,Manufacturer,Model,SerialNumber,Size"...
#fixed code @Override public HWDiskStore[] getDisks() { List<HWDiskStore> result; result = new ArrayList<>(); readMap.clear(); writeMap.clear(); populateReadWriteMaps(); Map<String, List<Object>> vals = WmiUtil.selectObjectsFrom(null, ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public long[] querySystemCpuLoadTicks() { // convert the Linux Jiffies to Milliseconds. long[] ticks = CpuStat.getSystemCpuLoadTicks(); long hz = LinuxOperatingSystem.getHz(); for (int i = 0; i < ticks.length; i++) { ...
#fixed code @Override public long[] querySystemCpuLoadTicks() { // convert the Linux Jiffies to Milliseconds. long[] ticks = CpuStat.getSystemCpuLoadTicks(); // In rare cases, /proc/stat reading fails. If so, try again. if (LongStream.of(ticks).sum() =...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void removeAllCounters() { // Remove all counter handles for (HANDLEByReference href : counterHandleMap.values()) { PerfDataUtil.removeCounter(href); } counterHandleMap.clear(); // Remove all queries for...
#fixed code public void removeAllCounters() { // Remove all counters from counterHandle map for (HANDLEByReference href : counterHandleMap.values()) { PerfDataUtil.removeCounter(href); } counterHandleMap.clear(); // Remove query ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static String getCardCodec(File cardDir) { String cardCodec = ""; for (File file : cardDir.listFiles()) { if (file.getName().startsWith("codec")) { cardCodec = FileUtil.getKeyValueMapFromFile(file.getPath(), ":").get("...
#fixed code private static String getCardCodec(File cardDir) { String cardCodec = ""; File[] cardFiles = cardDir.listFiles(); if (cardFiles == null) { return ""; } for (File file : cardDir.listFiles()) { if (file.getName().s...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public String getSystemSerialNumber() { if (this.cpuSerialNumber == null) { ArrayList<String> hwInfo = ExecutingCommand.runNative("system_profiler SPHardwareDataType"); // Mavericks and later for (String checkLin...
#fixed code @Override public String getSystemSerialNumber() { if (this.cpuSerialNumber == null) { int service = 0; MachPort masterPort = new MachPort(); int result = IOKit.INSTANCE.IOMasterPort(0, masterPort); if (result != 0) {...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static ArrayList<String> runNative(String cmdToRun) { Process p = null; try { p = Runtime.getRuntime().exec(cmdToRun); p.waitFor(); } catch (IOException e) { LOG.trace("", e); return null; ...
#fixed code public static ArrayList<String> runNative(String cmdToRun) { Process p = null; try { p = Runtime.getRuntime().exec(cmdToRun); } catch (IOException e) { LOG.trace("", e); return null; } BufferedReader...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator, String[] properties, ValueType[] propertyTypes) { if (propertyTypes.length > 1 && properties.length != propertyTypes.length) { throw...
#fixed code private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator, String[] properties, ValueType[] propertyTypes) { if (propertyTypes.length > 1 && properties.length != propertyTypes.length) { throw new I...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static <T extends Enum<T>> Map<T, Long> queryValues(Class<T> propertyEnum, String perfObject, String perfWmiClass) { Map<T, Long> valueMap = queryValuesFromPDH(propertyEnum, perfObject); if (valueMap.isEmpty()) { return que...
#fixed code public static <T extends Enum<T>> Map<T, Long> queryValues(Class<T> propertyEnum, String perfObject, String perfWmiClass) { // Check without locking for performance if (!failedQueryCache.contains(perfObject)) { failedQueryCacheLock.lock...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private List<OSFileStore> getWmiVolumes() { Map<String, List<String>> drives; List<OSFileStore> fs; String volume; long free; long total; fs = new ArrayList<>(); drives = WmiUtil.selectStringsFrom(null, "Win32_Lo...
#fixed code private List<OSFileStore> getWmiVolumes() { Map<String, List<Object>> drives; List<OSFileStore> fs; String volume; long free; long total; fs = new ArrayList<>(); drives = WmiUtil.selectObjectsFrom(null, "Win32_LogicalD...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public HWDiskStore[] getDisks() { List<HWDiskStore> result; result = new ArrayList<>(); Map<String, List<String>> vals = WmiUtil.selectStringsFrom(null, "Win32_DiskDrive", "Name,Manufacturer,Model,SerialNumber,Size"...
#fixed code @Override public HWDiskStore[] getDisks() { List<HWDiskStore> result; result = new ArrayList<>(); readMap.clear(); writeMap.clear(); populateReadWriteMaps(); Map<String, List<Object>> vals = WmiUtil.selectObjectsFrom(null, ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static boolean updateDiskStats(HWDiskStore diskStore, DASessionRef session, Map<String, String> mountPointMap, Map<String, String> logicalVolumeMap, Map<CFKey, CFStringRef> cfKeyMap) { // Now look up the device using the BSD Name to get its ...
#fixed code private static boolean updateDiskStats(HWDiskStore diskStore, DASessionRef session, Map<String, String> mountPointMap, Map<String, String> logicalVolumeMap, Map<CFKey, CFStringRef> cfKeyMap) { // Now look up the device using the BSD Name to get its ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static <T extends Enum<T>> Pair<List<String>, Map<T, List<Long>>> queryInstancesAndValues( Class<T> propertyEnum, String perfObject, String perfWmiClass) { Pair<List<String>, Map<T, List<Long>>> instancesAndValuesMap = queryInstancesAndValuesF...
#fixed code public static <T extends Enum<T>> Pair<List<String>, Map<T, List<Long>>> queryInstancesAndValues( Class<T> propertyEnum, String perfObject, String perfWmiClass) { // Check without locking for performance if (!failedQueryCache.contains(perfObject)) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void updateMeminfo() { long now = System.currentTimeMillis(); if (now - this.lastUpdate > 100) { if (!Psapi.INSTANCE.GetPerformanceInfo(perfInfo, perfInfo.size())) { LOG.error("Failed to get Performance Info. Error c...
#fixed code protected void updateMeminfo() { long now = System.currentTimeMillis(); if (now - this.lastUpdate > 100) { if (!Psapi.INSTANCE.GetPerformanceInfo(perfInfo, perfInfo.size())) { LOG.error("Failed to get Performance Info. Error code: {...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator, String[] properties, ValueType[] propertyTypes) { if (propertyTypes.length > 1 && properties.length != propertyTypes.length) { throw...
#fixed code private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator, String[] properties, ValueType[] propertyTypes) { if (propertyTypes.length > 1 && properties.length != propertyTypes.length) { throw new I...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private List<OSFileStore> getWmiVolumes() { Map<String, List<String>> drives; List<OSFileStore> fs; String volume; long free; long total; fs = new ArrayList<>(); drives = WmiUtil.selectStringsFrom(null, "Win32_Lo...
#fixed code private List<OSFileStore> getWmiVolumes() { Map<String, List<Object>> drives; List<OSFileStore> fs; String volume; long free; long total; fs = new ArrayList<>(); drives = WmiUtil.selectObjectsFrom(null, "Win32_LogicalD...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static Memory sysctl(String name) { IntByReference size = new IntByReference(); if (0 != SystemB.INSTANCE.sysctlbyname(name, null, size, null, 0)) { LOG.error(SYSCTL_FAIL, name, Native.getLastError()); return null; ...
#fixed code public static Memory sysctl(String name) { IntByReference size = new IntByReference(); if (0 != FreeBsdLibc.INSTANCE.sysctlbyname(name, null, size, null, 0)) { LOG.error(SYSCTL_FAIL, name, Native.getLastError()); return null; } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testGetChildProcesses() { // Get list of PIDS SystemInfo si = new SystemInfo(); OperatingSystem os = si.getOperatingSystem(); OSProcess[] processes = os.getProcesses(0, null); Map<Integer, Integer> childMap =...
#fixed code @Test public void testGetChildProcesses() { // Testing child processes is tricky because we don't really know a // priori what processes might have children, and if we do test the full // list vs. individual processes, we run into a race condition ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static <T extends Enum<T>> Map<T, Long> queryValues(Class<T> propertyEnum, String perfObject, String perfWmiClass) { Map<T, Long> valueMap = queryValuesFromPDH(propertyEnum, perfObject); if (valueMap.isEmpty()) { return que...
#fixed code public static <T extends Enum<T>> Map<T, Long> queryValues(Class<T> propertyEnum, String perfObject, String perfWmiClass) { // Check without locking for performance if (!failedQueryCache.contains(perfObject)) { failedQueryCacheLock.lock...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public long[][] queryProcessorCpuLoadTicks() { long[][] ticks = CpuStat.getProcessorCpuLoadTicks(getLogicalProcessorCount()); // convert the Linux Jiffies to Milliseconds. long hz = LinuxOperatingSystem.getHz(); for (int i =...
#fixed code @Override public long[][] queryProcessorCpuLoadTicks() { long[][] ticks = CpuStat.getProcessorCpuLoadTicks(getLogicalProcessorCount()); // In rare cases, /proc/stat reading fails. If so, try again. // In theory we should check all of them, but on f...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public OSFileStore[] getFileStores() { // Use getfsstat to map filesystem paths to types Map<String, String> fstype = new HashMap<>(); // Query with null to get total # required int numfs = SystemB.INSTANCE.getfsstat64(null, 0, 0); ...
#fixed code public OSFileStore[] getFileStores() { // Use getfsstat to map filesystem paths to types Map<String, String> fstype = new HashMap<>(); // Query with null to get total # required int numfs = SystemB.INSTANCE.getfsstat64(null, 0, 0); if (...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public double getCpuTemperature() { ArrayList<String> hwInfo = ExecutingCommand.runNative("wmic Temperature get CurrentReading"); for (String checkLine : hwInfo) { if (checkLine.length() == 0 || checkLine.toLowerCase().contains(...
#fixed code @Override public double getCpuTemperature() { // Initialize double tempC = 0d; // If Open Hardware Monitor identifier is set, we couldn't get through // normal WMI, and got ID from OHM at least once so go directly to OHM if (this.te...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public long[] querySystemCpuLoadTicks() { long[] ticks = new long[TickType.values().length]; WinBase.FILETIME lpIdleTime = new WinBase.FILETIME(); WinBase.FILETIME lpKernelTime = new WinBase.FILETIME(); WinBase.FILETIME lpUs...
#fixed code @Override public long[] querySystemCpuLoadTicks() { // To get load in processor group scenario, we need perfmon counters, but the // _Total instance is an average rather than total (scaled) number of ticks // which matches GetSystemTimes() results....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void populateReadWriteMaps() { // Although the field names say "PerSec" this is the Raw Data from which // the associated fields are populated in the Formatted Data class, so // in fact this is the data we want Map<String, List<St...
#fixed code private void populateReadWriteMaps() { // Although the field names say "PerSec" this is the Raw Data from which // the associated fields are populated in the Formatted Data class, so // in fact this is the data we want Map<String, List<Object>>...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private DmidecodeStrings readDmiDecode() { String manufacturer = null; String version = null; String releaseDate = null; // $ sudo dmidecode -t bios // # dmidecode 3.0 // Scanning /dev/mem for entry point. // SMBI...
#fixed code private DmidecodeStrings readDmiDecode() { String manufacturer = null; String version = null; String releaseDate = ""; // $ sudo dmidecode -t bios // # dmidecode 3.0 // Scanning /dev/mem for entry point. // SMBIOS 2.7 p...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator, String[] properties, ValueType[] propertyTypes) { if (properties.length != propertyTypes.length) { throw new IllegalArgumentExceptio...
#fixed code private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator, String[] properties, ValueType[] propertyTypes) { if (propertyTypes.length > 1 && properties.length != propertyTypes.length) { throw new I...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected void updateSwap() { updateMeminfo(); Map<String, List<Long>> usage = WmiUtil.selectUint32sFrom(null, "Win32_PerfRawData_PerfOS_PagingFile", "PercentUsage,PercentUsage_Base", "WHERE Name=\"_Total\""); if (!u...
#fixed code @Override protected void updateSwap() { updateMeminfo(); this.swapUsed = PdhUtil.queryCounter(pdhPagingPercentUsageCounter) * this.pageSize; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public long getTotal() { if (totalMemory == 0) { Scanner in = null; try { in = new Scanner(new FileReader("/proc/meminfo")); } catch (FileNotFoundException e) { totalMemory = 0; return totalMemory; } in.useDelimiter("\n"); while (in.hasNext(...
#fixed code public long getTotal() { if (totalMemory == 0) { Sysinfo info = new Sysinfo(); if (0 != Libc.INSTANCE.sysinfo(info)) throw new LastErrorException("Error code: " + Native.getLastError()); totalMemory = info.totalram.longValue() * info.mem_unit; } return t...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static UsbDevice[] getUsbDevices() { // Get heirarchical list of USB devices List<String> xml = ExecutingCommand.runNative("system_profiler SPUSBDataType -xml"); // Look for <key>_items</key> which prcedes <array> ... </array> // E...
#fixed code public static UsbDevice[] getUsbDevices() { // Reusable buffer for getting IO name strings Pointer buffer = new Memory(128); // io_name_t is char[128] // Build a list of devices with no parent; these will be the roots List<Long> usbControllers ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static ArrayList<String> runNative(String[] cmdToRunWithArgs) { Process p = null; try { p = Runtime.getRuntime().exec(cmdToRunWithArgs); } catch (IOException e) { LOG.trace("", e); return null; }...
#fixed code public static ArrayList<String> runNative(String[] cmdToRunWithArgs) { Process p = null; try { p = Runtime.getRuntime().exec(cmdToRunWithArgs); } catch (IOException e) { LOG.trace("", e); return null; } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public String getFamily() { if (this._family == null) { try (final Scanner in = new Scanner(new FileReader("/etc/os-release"))) { in.useDelimiter("\n"); while (in.hasNext()) { String[]...
#fixed code @Override public String getFamily() { if (this._family == null) { String etcOsRelease = getReleaseFilename(); try { this.osRelease = FileUtil.readFile(etcOsRelease); for (String line : this.osRelease) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private List<OSFileStore> getWmiVolumes() { Map<String, List<String>> drives; List<OSFileStore> fs; String volume; long free; long total; fs = new ArrayList<>(); drives = WmiUtil.selectStringsFrom(null, "Win32_Lo...
#fixed code private List<OSFileStore> getWmiVolumes() { Map<String, List<Object>> drives; List<OSFileStore> fs; String volume; long free; long total; fs = new ArrayList<>(); drives = WmiUtil.selectObjectsFrom(null, "Win32_LogicalD...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean updateAttributes() { try { File ifDir = new File(String.format("/sys/class/net/%s/statistics", getName())); if (!ifDir.isDirectory()) { return false; } } catch (SecurityExce...
#fixed code @Override public boolean updateAttributes() { try { File ifDir = new File(String.format("/sys/class/net/%s/statistics", getName())); if (!ifDir.isDirectory()) { return false; } } catch (SecurityException ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private List<OSFileStore> getWmiVolumes() { Map<String, List<String>> drives; List<OSFileStore> fs; String volume; long free; long total; fs = new ArrayList<>(); drives = WmiUtil.selectStringsFrom(null, "Win32_Lo...
#fixed code private List<OSFileStore> getWmiVolumes() { Map<String, List<Object>> drives; List<OSFileStore> fs; String volume; long free; long total; fs = new ArrayList<>(); drives = WmiUtil.selectObjectsFrom(null, "Win32_LogicalD...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static Memory sysctl(String name) { IntByReference size = new IntByReference(); if (0 != SystemB.INSTANCE.sysctlbyname(name, null, size, null, 0)) { LOG.error(SYSCTL_FAIL, name, Native.getLastError()); return null; ...
#fixed code public static Memory sysctl(String name) { IntByReference size = new IntByReference(); if (0 != FreeBsdLibc.INSTANCE.sysctlbyname(name, null, size, null, 0)) { LOG.error(SYSCTL_FAIL, name, Native.getLastError()); return null; } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static <T extends Enum<T>> Pair<List<String>, Map<T, List<Long>>> queryInstancesAndValues( Class<T> propertyEnum, String perfObject, String perfWmiClass) { Pair<List<String>, Map<T, List<Long>>> instancesAndValuesMap = queryInstancesAndValuesF...
#fixed code public static <T extends Enum<T>> Pair<List<String>, Map<T, List<Long>>> queryInstancesAndValues( Class<T> propertyEnum, String perfObject, String perfWmiClass) { // Check without locking for performance if (!failedQueryCache.contains(perfObject)) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public OSService[] getServices() { // Get running services List<OSService> services = new ArrayList<>(); Set<String> running = new HashSet<>(); for (OSProcess p : getChildProcesses(1, 0, ProcessSort.PID)) { OSSer...
#fixed code @Override public OSService[] getServices() { // Get running services List<OSService> services = new ArrayList<>(); Set<String> running = new HashSet<>(); for (OSProcess p : getChildProcesses(1, 0, ProcessSort.PID)) { OSService s...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void populatePartitionMaps() { driveToPartitionMap.clear(); partitionToLogicalDriveMap.clear(); partitionMap.clear(); // For Regexp matching DeviceIDs Matcher mAnt; Matcher mDep; // Map drives to partition...
#fixed code private void populatePartitionMaps() { driveToPartitionMap.clear(); partitionToLogicalDriveMap.clear(); partitionMap.clear(); // For Regexp matching DeviceIDs Matcher mAnt; Matcher mDep; // Map drives to partitions ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator, String[] properties, ValueType[] propertyTypes, WbemServices svc) { if (propertyTypes.length > 1 && properties.length != propertyTypes.length) {...
#fixed code private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator, String[] properties, ValueType[] propertyTypes, WbemServices svc) { if (propertyTypes.length > 1 && properties.length != propertyTypes.length) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private List<OSFileStore> getWmiVolumes() { Map<String, List<String>> drives; List<OSFileStore> fs; String volume; long free; long total; fs = new ArrayList<>(); drives = WmiUtil.selectStringsFrom(null, "Win32_Lo...
#fixed code private List<OSFileStore> getWmiVolumes() { Map<String, List<Object>> drives; List<OSFileStore> fs; String volume; long free; long total; fs = new ArrayList<>(); drives = WmiUtil.selectObjectsFrom(null, "Win32_LogicalD...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static <T extends Enum<T>> Pair<List<String>, Map<T, List<Long>>> queryInstancesAndValues( Class<T> propertyEnum, String perfObject, String perfWmiClass) { Pair<List<String>, Map<T, List<Long>>> instancesAndValuesMap = queryInstancesAndValuesF...
#fixed code public static <T extends Enum<T>> Pair<List<String>, Map<T, List<Long>>> queryInstancesAndValues( Class<T> propertyEnum, String perfObject, String perfWmiClass) { // Check without locking for performance if (!failedQueryCache.contains(perfObject)) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static UsbDevice[] getUsbDevices() { // Start by collecting information for all PNP devices. While in theory // these could be individually queried with a WHERE clause, grabbing // them all up front incurs minimal memory overhead in exchan...
#fixed code public static UsbDevice[] getUsbDevices() { // Start by collecting information for all PNP devices. While in theory // these could be individually queried with a WHERE clause, grabbing // them all up front incurs minimal memory overhead in exchange for...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public HWDiskStore[] getDisks() { List<HWDiskStore> result; result = new ArrayList<>(); Map<String, List<String>> vals = WmiUtil.selectStringsFrom(null, "Win32_DiskDrive", "Name,Manufacturer,Model,SerialNumber,Size"...
#fixed code @Override public HWDiskStore[] getDisks() { List<HWDiskStore> result; result = new ArrayList<>(); readMap.clear(); writeMap.clear(); populateReadWriteMaps(); Map<String, List<Object>> vals = WmiUtil.selectObjectsFrom(null, ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static ArrayList<String> runNative(String cmdToRun) { Process p = null; try { p = Runtime.getRuntime().exec(cmdToRun); //p.waitFor(); } catch (IOException e) { return null; } BufferedReader reader = new BufferedReader(new InputStreamReader( p...
#fixed code public static ArrayList<String> runNative(String cmdToRun) { Process p = null; try { p = Runtime.getRuntime().exec(cmdToRun); p.waitFor(); } catch (IOException e) { return null; } catch (InterruptedException e) { e.printStackTrace(); } BufferedReader rea...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator, String[] properties, ValueType[] propertyTypes) { if (propertyTypes.length > 1 && properties.length != propertyTypes.length) { throw...
#fixed code private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator, String[] properties, ValueType[] propertyTypes) { if (propertyTypes.length > 1 && properties.length != propertyTypes.length) { throw new I...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected void updateSwap() { updateMeminfo(); Map<String, List<Long>> usage = WmiUtil.selectUint32sFrom(null, "Win32_PerfRawData_PerfOS_PagingFile", "PercentUsage,PercentUsage_Base", "WHERE Name=\"_Total\""); if (!u...
#fixed code @Override protected void updateSwap() { updateMeminfo(); this.swapUsed = PdhUtil.queryCounter(pdhPagingPercentUsageCounter) * this.pageSize; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void findWhere() { class Book { public final String title; public final String author; public final Integer year; public Book(final String title, final String author, final Integer year) { ...
#fixed code @Test public void findWhere() { class Book { public final String title; public final String author; public final Integer year; public Book(final String title, final String author, final Integer year) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test @SuppressWarnings("unchecked") public void chainArray() { final List<Map<String, Object>> stooges = new ArrayList<Map<String, Object>>() { { add(new LinkedHashMap<String, Object>() { { put("name", "curly"); put("age", 25); } }); ...
#fixed code @Test @SuppressWarnings("unchecked") public void chainArray() { final List<Map<String, Object>> stooges = new ArrayList<Map<String, Object>>() { { add(new LinkedHashMap<String, Object>() { { put("name", "curly"); put("age", 25); } }); a...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void find() { final Integer result = _.find(asList(1, 2, 3, 4, 5, 6), new Predicate<Integer>() { public Boolean apply(Integer item) { return item % 2 == 0; } }); assertEquals("...
#fixed code @Test public void find() { final Optional<Integer> result = _.find(asList(1, 2, 3, 4, 5, 6), new Predicate<Integer>() { public Boolean apply(Integer item) { return item % 2 == 0; } }); assertEqual...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void findWhere() { class Book { public final String title; public final String author; public final Integer year; public Book(final String title, final String author, final Integer year) { ...
#fixed code @Test public void findWhere() { class Book { public final String title; public final String author; public final Integer year; public Book(final String title, final String author, final Integer year) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void singleOrNull() { U<Integer> uWithMoreElement = new U<>(asList(1, 2, 3)); U<Integer> uWithOneElement = new U<>(asList(1)); final Integer result1 = U.singleOrNull(asList(1, 2, 3)); assertNull(result1); final int re...
#fixed code @Test public void singleOrNull() { U<Integer> uWithMoreElement = new U<>(asList(1, 2, 3)); U<Integer> uWithOneElement = new U<>(singletonList(1)); final Integer result1 = U.singleOrNull(asList(1, 2, 3)); assertNull(result1); final int r...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void lastOrNull() { final Integer result = $.lastOrNull(asList(5, 4, 3, 2, 1)); assertEquals("1", result.toString()); final Integer resultObj = new $<Integer>(asList(5, 4, 3, 2, 1)).lastOrNull(); assertEquals("1", resultO...
#fixed code @Test public void lastOrNull() { final Integer result = $.lastOrNull(asList(5, 4, 3, 2, 1)); assertEquals("1", result.toString()); final Integer resultObj = new $<Integer>(asList(5, 4, 3, 2, 1)).lastOrNull(); assertEquals("1", resultObj.toS...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static <E, F extends Number> Double average(final Iterable<E> iterable, final Function<E, F> func) { F sum = sum(iterable, func); return sum.doubleValue() / size(iterable); } #location 3 ...
#fixed code public static <E, F extends Number> Double average(final Iterable<E> iterable, final Function<E, F> func) { F sum = sum(iterable, func); if (sum == null) { return null; } return sum.doubleValue() / size(iterable); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void firstOrNull() { final Integer result = $.firstOrNull(asList(5, 4, 3, 2, 1)); assertEquals("5", result.toString()); final Integer resultObj = new $<Integer>(asList(5, 4, 3, 2, 1)).firstOrNull(); assertEquals("5", resu...
#fixed code @Test public void firstOrNull() { final Integer result = $.firstOrNull(asList(5, 4, 3, 2, 1)); assertEquals("5", result.toString()); final Integer resultObj = new $<Integer>(asList(5, 4, 3, 2, 1)).firstOrNull(); assertEquals("5", resultObj....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static <T extends Number> double mean(final Iterable<T> iterable) { T result = null; int count = 0; for (final T item : iterable) { result = add(result, item); count += 1; } return result.doubleValue...
#fixed code public static <T extends Number> double mean(final Iterable<T> iterable) { T result = null; int count = 0; for (final T item : iterable) { result = add(result, item); count += 1; } if (result == null) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void detect() { final Integer result = _.detect(asList(1, 2, 3, 4, 5, 6), new Predicate<Integer>() { public Boolean apply(Integer item) { return item % 2 == 0; } }); assertEqua...
#fixed code @Test public void detect() { final Optional<Integer> result = _.detect(asList(1, 2, 3, 4, 5, 6), new Predicate<Integer>() { public Boolean apply(Integer item) { return item % 2 == 0; } }); assertE...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testLoadingLocalTime() throws Exception { Vertex v = this.sqlgGraph.addVertex(T.label, "Person", "createOn", LocalTime.now()); this.sqlgGraph.tx().commit(); this.sqlgGraph.close(); //noinspection Duplicates t...
#fixed code @Test public void testLoadingLocalTime() throws Exception { Vertex v = this.sqlgGraph.addVertex(T.label, "Person", "createOn", LocalTime.now()); this.sqlgGraph.tx().commit(); this.sqlgGraph.close(); //noinspection Duplicates try (Sq...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testCreateEdgeBetweenVerticesPropertiesEagerlyLoadedOnHasHas() { Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john"); Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "peter"); th...
#fixed code @Test public void testCreateEdgeBetweenVerticesPropertiesEagerlyLoadedOnHasHas() { Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john"); Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "peter"); this.sql...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testBatchUpdatePersistentVertices() { Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "a"); Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person", "surname", "b"); this.sqlgGraph.tx().commit(); asser...
#fixed code @Test public void testBatchUpdatePersistentVertices() { Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "a"); Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person", "surname", "b"); this.sqlgGraph.tx().commit(); assertEqual...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testBatchUpdatePersistentVerticesAllTypes() { Assume.assumeTrue(this.sqlgGraph.features().vertex().properties().supportsFloatValues()); Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "a"); Vertex v2 = this...
#fixed code @Test public void testBatchUpdatePersistentVerticesAllTypes() { Assume.assumeTrue(this.sqlgGraph.features().vertex().properties().supportsFloatValues()); Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "a"); Vertex v2 = this.sqlgG...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testLoadVertexProperties() { Vertex marko = this.sqlgGraph.addVertex(T.label, "Person", "name", "marko"); this.sqlgGraph.tx().commit(); marko = this.sqlgGraph.v(marko.id()); Assert.assertEquals("marko", marko.propert...
#fixed code @Test public void testLoadVertexProperties() { Vertex marko = this.sqlgGraph.addVertex(T.label, "Person", "name", "marko"); this.sqlgGraph.tx().commit(); marko = this.sqlgGraph.traversal().V(marko.id()).next(); Assert.assertEquals("marko", ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testCreateEdgeBetweenVerticesPropertiesEagerlyLoadedOnHas() { Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john"); Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "peter"); this....
#fixed code @Test public void testCreateEdgeBetweenVerticesPropertiesEagerlyLoadedOnHas() { Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john"); Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "peter"); this.sqlgGr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void loadResultSet(ResultSet resultSet, List<VertexLabel> inForeignKeys, List<VertexLabel> outForeignKeys) throws SQLException { SchemaTable inVertexColumnName = null; SchemaTable outVertexColumnName = null; ResultSetMetaData resultSetMet...
#fixed code private void loadResultSet(ResultSet resultSet, List<VertexLabel> inForeignKeys, List<VertexLabel> outForeignKeys) throws SQLException { SchemaTable inVertexColumnName = null; SchemaTable outVertexColumnName = null; ResultSetMetaData resultSetMetaData ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testBatchUpdatePersistentVertices() { Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "a"); Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person", "surname", "b"); this.sqlgGraph.tx().commit(); asser...
#fixed code @Test public void testBatchUpdatePersistentVertices() { Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "a"); Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person", "surname", "b"); this.sqlgGraph.tx().commit(); assertEqual...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testCreateEdgeBetweenVerticesPropertiesEagerlyLoadedOnHas() { Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john"); Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "peter"); this....
#fixed code @Test public void testCreateEdgeBetweenVerticesPropertiesEagerlyLoadedOnHas() { Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john"); Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "peter"); this.sqlgGr...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testMultipleReferencesToSameVertex2Instances() { Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john"); this.sqlgGraph.tx().commit(); //_v1 is in the transaction cache //v1 is not Vertex _v1...
#fixed code @Test public void testMultipleReferencesToSameVertex2Instances() { Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john"); this.sqlgGraph.tx().commit(); //_v1 is in the transaction cache //v1 is not Vertex _v1 = thi...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testCreateEdgeBetweenVerticesPropertiesEagerlyLoadedOnHasHas() { Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john"); Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "peter"); th...
#fixed code @Test public void testCreateEdgeBetweenVerticesPropertiesEagerlyLoadedOnHasHas() { Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john"); Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "peter"); this.sql...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @BeforeClass public static void beforeClass() throws ClassNotFoundException, IOException, PropertyVetoException, NamingException, ConfigurationException { URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties"); ...
#fixed code @BeforeClass public static void beforeClass() throws Exception { URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties"); configuration = new PropertiesConfiguration(sqlProperties); if (!configuration.conta...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testLoadingJson() throws Exception { Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsJson()); ObjectMapper objectMapper = new ObjectMapper(); ObjectNode json = new ObjectNode(objectMapper.getNodeFactory()); ...
#fixed code @Test public void testLoadingJson() throws Exception { Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsJson()); ObjectMapper objectMapper = new ObjectMapper(); ObjectNode json = new ObjectNode(objectMapper.getNodeFactory()); json....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testVertexTransactionalCache2() { Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person"); Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person"); Vertex v3 = this.sqlgGraph.addVertex(T.label, "Person"); Edge e1 = v...
#fixed code @Test public void testVertexTransactionalCache2() { Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person"); Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person"); Vertex v3 = this.sqlgGraph.addVertex(T.label, "Person"); Edge e1 = v1.addE...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testBatchUpdateDifferentPropertiesDifferentRows() { Vertex sqlgVertex1 = this.sqlgGraph.addVertex(T.label, "Person", "property1", "a1", "property2", "b1", "property3", "c1"); Vertex sqlgVertex2 = this.sqlgGraph.addVertex(T.label, "...
#fixed code @Test public void testBatchUpdateDifferentPropertiesDifferentRows() { Vertex sqlgVertex1 = this.sqlgGraph.addVertex(T.label, "Person", "property1", "a1", "property2", "b1", "property3", "c1"); Vertex sqlgVertex2 = this.sqlgGraph.addVertex(T.label, "Person...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testLoadingDatasourceFromJndi() throws Exception { SqlgGraph g = SqlgGraph.open(configuration); assertNotNull(g.getSqlDialect()); assertNotNull(g.getSqlgDataSource().get(configuration.getString("jdbc.url"))); } ...
#fixed code @Test public void testLoadingDatasourceFromJndi() throws Exception { SqlgGraph g = SqlgGraph.open(configuration); assertNotNull(g.getSqlDialect()); assertEquals(configuration.getString("jdbc.url"), g.getJdbcUrl()); assertNotNull(g.getConnec...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testLoadingLocalDate() throws Exception { Vertex v = this.sqlgGraph.addVertex(T.label, "Person", "createOn", LocalDate.now()); this.sqlgGraph.tx().commit(); this.sqlgGraph.close(); //noinspection Duplicates t...
#fixed code @Test public void testLoadingLocalDate() throws Exception { Vertex v = this.sqlgGraph.addVertex(T.label, "Person", "createOn", LocalDate.now()); this.sqlgGraph.tx().commit(); this.sqlgGraph.close(); //noinspection Duplicates try (Sq...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testLoadPropertiesOnUpdate() { Vertex vertex = this.sqlgGraph.addVertex(T.label, "Person", "property1", "a", "property2", "b"); this.sqlgGraph.tx().commit(); vertex = this.sqlgGraph.v(vertex.id()); vertex.property("...
#fixed code @Test public void testLoadPropertiesOnUpdate() { Vertex vertex = this.sqlgGraph.addVertex(T.label, "Person", "property1", "a", "property2", "b"); this.sqlgGraph.tx().commit(); vertex = this.sqlgGraph.traversal().V(vertex.id()).next(); vert...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Map<String, Set<IndexRef>> extractIndices(Connection conn, String catalog, String schema) throws SQLException{ // copied and simplified from the postgres JDBC driver class (PgDatabaseMetaData) String sql = "SELECT NULL AS TABLE_CAT, n.n...
#fixed code @Override public Map<String, Set<IndexRef>> extractIndices(Connection conn, String catalog, String schema) throws SQLException{ // copied and simplified from the postgres JDBC driver class (PgDatabaseMetaData) String sql = "SELECT NULL AS TABLE_CAT, n.nspname...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testMultipleReferencesToSameVertex() { Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john"); this.sqlgGraph.tx().commit(); Assert.assertEquals("john", v1.value("name")); //_v1 is in the transaction...
#fixed code @Test public void testMultipleReferencesToSameVertex() { Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "john"); this.sqlgGraph.tx().commit(); Assert.assertEquals("john", v1.value("name")); //_v1 is in the transaction cache...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testCreateEdgeBetweenVertices() { Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person"); Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person"); this.sqlgGraph.tx().commit(); person1 = this.sqlgGraph.v(p...
#fixed code @Test public void testCreateEdgeBetweenVertices() { Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person"); Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person"); this.sqlgGraph.tx().commit(); person1 = this.sqlgGraph.traversal...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @BeforeClass public static void beforeClass() throws Exception { URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties"); configuration = new PropertiesConfiguration(sqlProperties); if (!configuration...
#fixed code @BeforeClass public static void beforeClass() throws Exception { URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties"); configuration = new PropertiesConfiguration(sqlProperties); if (!configuration.conta...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @BeforeClass public static void beforeClass() throws ClassNotFoundException, IOException, PropertyVetoException, NamingException, ConfigurationException { URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties"); ...
#fixed code @BeforeClass public static void beforeClass() throws Exception { URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties"); configuration = new PropertiesConfiguration(sqlProperties); if (!configuration.conta...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testBatchUpdatePersistentVerticesAllTypes() { Assume.assumeTrue(this.sqlgGraph.features().vertex().properties().supportsFloatValues()); Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "a"); Vertex v2 = this...
#fixed code @Test public void testBatchUpdatePersistentVerticesAllTypes() { Assume.assumeTrue(this.sqlgGraph.features().vertex().properties().supportsFloatValues()); Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "a"); Vertex v2 = this.sqlgG...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testLoadingLocalDateTime() throws Exception { Vertex v = this.sqlgGraph.addVertex(T.label, "Person", "createOn", LocalDateTime.now()); this.sqlgGraph.tx().commit(); this.sqlgGraph.close(); //noinspection Duplicates ...
#fixed code @Test public void testLoadingLocalDateTime() throws Exception { Vertex v = this.sqlgGraph.addVertex(T.label, "Person", "createOn", LocalDateTime.now()); this.sqlgGraph.tx().commit(); this.sqlgGraph.close(); //noinspection Duplicates ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testVertexTransactionalCache() { Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person"); Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person"); Vertex v3 = this.sqlgGraph.addVertex(T.label, "Person"); v1.addEdge("...
#fixed code @Test public void testVertexTransactionalCache() { Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person"); Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person"); Vertex v3 = this.sqlgGraph.addVertex(T.label, "Person"); v1.addEdge("friend...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testCreateEdgeBetweenVertices() { Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person"); Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person"); this.sqlgGraph.tx().commit(); person1 = this.sqlgGraph.v(p...
#fixed code @Test public void testCreateEdgeBetweenVertices() { Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person"); Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person"); this.sqlgGraph.tx().commit(); person1 = this.sqlgGraph.traversal...
Below is the vulnerable code, please generate the patch based on the following information.