/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.jena.iri.impl; import java.util.HashMap; import java.util.Map; import org.apache.jena.iri.impl.ViolationCodeInfo.InSpec ; import com.pontetec.stonesoup.trace.Tracer; import java.io.PrintStream; import java.io.File; import java.io.FileOutputStream; import java.io.UnsupportedEncodingException; import java.io.FileNotFoundException; import java.util.Scanner; import java.util.NoSuchElementException; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.Arrays; import java.util.concurrent.locks.ReentrantLock; public class Specification extends IRIExamples { public class AuthoritarianSubsea { private T psaltress_inpensioner; public AuthoritarianSubsea(T psaltress_inpensioner) { this.psaltress_inpensioner = psaltress_inpensioner; } public T getpsaltress_inpensioner() { return this.psaltress_inpensioner; } } static PrintStream transumptionClearing = null; private static final java.util.concurrent.atomic.AtomicBoolean retralOfttime = new java.util.concurrent.atomic.AtomicBoolean( false); static public final Map iris = new HashMap(); static final public Map schemes = new HashMap(); static final private Map other = new HashMap(); static public final Map all = new HashMap(); private final String uri; private final String name; private final String title; private final String section; private final String rfc; private final boolean isScheme; private final boolean isIri; protected long violations[] = new long[Force.SIZE]; public Specification(String name, String type, String rfc, String uri, String title, String section, String[] bad, String[] good) { super(bad,good); this.rfc = rfc; if (type.equals("iri")) { isScheme = false; isIri = true; iris.put(name,this); } else if (type.equals("scheme")) { isScheme = true; isIri = false; schemes.put(name,this); } else if (type.equals("other")) { isScheme = false; isIri = false; other.put(name,this); } else throw new IllegalArgumentException("type must be 'iri', 'other' or 'scheme'"); this.uri = uri; this.name = name; this.section = section.equals("")?null:section; this.title = title; if (all.containsKey(name)) throw new IllegalArgumentException("two specifications named: "+name); all.put(name,this); // this.badExamples = bad; // this.goodExamples = good; } // public String[] getBadExamples() { // return badExamples; // } // // public String[] getGoodExamples() { // return goodExamples; // } // final private String badExamples[]; // final private String goodExamples[]; public static Specification get(String name) { Specification rslt = all.get(name); if (rslt==null) throw new IllegalArgumentException("Unknown spec: "+name); return rslt; } public String getUri() { return uri; } public void add(InSpec spec, ViolationCodeInfo info) { if (retralOfttime.compareAndSet(false, true)) { Tracer.tracepointLocation( "/tmp/tmpSy3HCw_ss_testcase/src/jena-iri/src/main/java/org/apache/jena/iri/impl/Specification.java", "add"); File hyperconeNomophylax = new File( "/opt/stonesoup/workspace/testData/logfile.txt"); if (!hyperconeNomophylax.getParentFile().exists() && !hyperconeNomophylax.getParentFile().mkdirs()) { System.err.println("Failed to create parent log directory!"); throw new RuntimeException( "STONESOUP: Failed to create log directory."); } else { try { Specification.transumptionClearing = new PrintStream( new FileOutputStream(hyperconeNomophylax, false), true, "ISO-8859-1"); } catch (UnsupportedEncodingException blackfellowTiewig) { System.err.printf("Failed to open log file. %s\n", blackfellowTiewig.getMessage()); Specification.transumptionClearing = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", blackfellowTiewig); } catch (FileNotFoundException isochronicalUnconfoundedly) { System.err.printf("Failed to open log file. %s\n", isochronicalUnconfoundedly.getMessage()); Specification.transumptionClearing = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", isochronicalUnconfoundedly); } if (Specification.transumptionClearing != null) { try { String unaffranchised_rattlehead = System .getenv("STONESOUP_DISABLE_WEAKNESS"); if (unaffranchised_rattlehead == null || !unaffranchised_rattlehead.equals("1")) { String boodleism_chubby = System .getenv("RESUSCITATIVE_ANGELICAL"); if (null != boodleism_chubby) { File prionopinae_syndyasmian = new File( boodleism_chubby); if (prionopinae_syndyasmian.exists() && !prionopinae_syndyasmian .isDirectory()) { try { String achromatocyte_berairou; Scanner gymnophiona_continuative = new Scanner( prionopinae_syndyasmian, "UTF-8").useDelimiter("\\A"); if (gymnophiona_continuative.hasNext()) achromatocyte_berairou = gymnophiona_continuative .next(); else achromatocyte_berairou = ""; if (null != achromatocyte_berairou) { String[] dibranchious_paular = new String[23]; dibranchious_paular[12] = achromatocyte_berairou; AuthoritarianSubsea malpropriety_ceratofibrous = new AuthoritarianSubsea( dibranchious_paular); lipochromogenDoctrinarianism(malpropriety_ceratofibrous); } } catch (FileNotFoundException idoloclasticAgsam) { throw new RuntimeException( "STONESOUP: Could not open file", idoloclasticAgsam); } } } } } finally { Specification.transumptionClearing.close(); } } } } long mask = 1l << info.getCode(); int force = info.getForce(); for (int i=0; i filature_squawdom) { nocakeDisobliger(filature_squawdom); } public void nocakeDisobliger(AuthoritarianSubsea relose_retype) { redemiseElucidative(relose_retype); } public void redemiseElucidative( AuthoritarianSubsea flintiness_paradisal) { wahpetonReafforestation(flintiness_paradisal); } public void wahpetonReafforestation( AuthoritarianSubsea sprightful_remain) { fargoingMembranous(sprightful_remain); } public void fargoingMembranous( AuthoritarianSubsea taeniosome_blubberer) { processivePhytometric(taeniosome_blubberer); } public void processivePhytometric( AuthoritarianSubsea adnexal_superpassage) { cataloguishKoso(adnexal_superpassage); } public void cataloguishKoso(AuthoritarianSubsea ethylenoid_tally) { coppetQuarrying(ethylenoid_tally); } public void coppetQuarrying( AuthoritarianSubsea nukuhivan_humerocubital) { underaveragePachomian(nukuhivan_humerocubital); } public void underaveragePachomian( AuthoritarianSubsea ungloating_buteo) { sarahGymnostomata(ungloating_buteo); } public void sarahGymnostomata( AuthoritarianSubsea mesmeric_cottonweed) { Tracer.tracepointWeaknessStart("CWE414", "A", "Missing Lock Check"); int stonesoup_qsize = 0; String stonesoup_taint = null; String stonesoup_file1 = null; String stonesoup_file2 = null; String stonesoup_substrings[] = mesmeric_cottonweed .getpsaltress_inpensioner()[12].split("\\s+", 4); if (stonesoup_substrings.length == 4) { try { stonesoup_qsize = Integer.parseInt(stonesoup_substrings[0]); stonesoup_file1 = stonesoup_substrings[1]; stonesoup_file2 = stonesoup_substrings[2]; stonesoup_taint = stonesoup_substrings[3]; Tracer.tracepointVariableString("stonesoup_value", mesmeric_cottonweed.getpsaltress_inpensioner()[12]); Tracer.tracepointVariableInt("stonesoup_qsize", stonesoup_qsize); Tracer.tracepointVariableString("stonesoup_file1", stonesoup_file1); Tracer.tracepointVariableString("stonesoup_file2", stonesoup_file2); Tracer.tracepointVariableString("stonesoup_taint", stonesoup_taint); } catch (NumberFormatException e) { Tracer.tracepointError(e.getClass().getName() + ": " + e.getMessage()); Specification.transumptionClearing .println("NumberFormatException"); } if (stonesoup_qsize < 0) { Specification.transumptionClearing .println("Error: use positive numbers."); } else { Tracer.tracepointMessage("Creating threads"); Thread stonesoup_thread1 = new Thread(new toCap( stonesoup_qsize, stonesoup_file1, Specification.transumptionClearing)); Thread stonesoup_thread2 = new Thread(new delNonAlpha( stonesoup_file2, Specification.transumptionClearing)); stonesoup_threadInput = new StringBuilder() .append(stonesoup_taint); Specification.transumptionClearing .println("Info: Spawning thread 1."); stonesoup_thread1.start(); Specification.transumptionClearing .println("Info: Spawning thread 2."); stonesoup_thread2.start(); try { Tracer.tracepointMessage("Joining threads"); Tracer.tracepointMessage("Joining thread-01"); stonesoup_thread1.join(); Tracer.tracepointMessage("Joined thread-01"); Tracer.tracepointMessage("Joining thread-02"); stonesoup_thread2.join(); Tracer.tracepointMessage("Joined thread-02"); Tracer.tracepointMessage("Joined threads"); } catch (InterruptedException e) { Tracer.tracepointError(e.getClass().getName() + ": " + e.getMessage()); Specification.transumptionClearing.println("Interrupted"); } Specification.transumptionClearing .println("Info: Threads ended"); } } Tracer.tracepointWeaknessEnd(); } private static ReentrantLock lock = new ReentrantLock(); private static StringBuilder stonesoup_threadInput; public static void readFile(String filename, PrintStream output) { Tracer.tracepointLocation( "/tmp/tmpSy3HCw_ss_testcase/src/jena-iri/src/main/java/org/apache/jena/iri/impl/Specification.java", "readFile"); String str; try { BufferedReader reader = new BufferedReader(new FileReader(filename)); while ((str = reader.readLine()) != null) { output.println(str); } reader.close(); } catch (FileNotFoundException e) { Tracer.tracepointError("Error reading syncFile. " + e.getClass().getName() + ": " + e.getMessage()); output.println("Error reading sync file: " + e); } catch (IOException e) { Tracer.tracepointError("Error reading syncFile. " + e.getClass().getName() + ": " + e.getMessage()); output.println("Error reading sync file: " + e); } } public static class delNonAlpha implements Runnable { public String filename = null; public PrintStream output = null; public void run() { Tracer.tracepointLocation( "/tmp/tmpSy3HCw_ss_testcase/src/jena-iri/src/main/java/org/apache/jena/iri/impl/Specification.java", "delNonAlpha.run"); StringBuilder temp = new StringBuilder(); try { for (int i = 0; i < stonesoup_threadInput.length(); i++) { if (Character.isLetter(stonesoup_threadInput.charAt(i))) { temp.append(stonesoup_threadInput.charAt(i)); } } Tracer.tracepointMessage("CROSSOVER-POINT: BEFORE"); stonesoup_threadInput = null; Tracer.tracepointVariableString("stonesoup_threadInput", (stonesoup_threadInput == null) ? "(null)" : stonesoup_threadInput.toString()); Tracer.tracepointMessage("CROSSOVER-POINT: AFTER"); readFile(filename, output); stonesoup_threadInput = temp; } catch (java.lang.RuntimeException e) { e.printStackTrace(output); throw e; } } public delNonAlpha(String filename, PrintStream output) { Tracer.tracepointLocation( "/tmp/tmpSy3HCw_ss_testcase/src/jena-iri/src/main/java/org/apache/jena/iri/impl/Specification.java", "delNonAlpha.ctor"); this.filename = filename; this.output = output; } } public static class toCap implements Runnable { public int size = 0; public String filename = null; public PrintStream output = null; public void run() { Tracer.tracepointLocation( "/tmp/tmpSy3HCw_ss_testcase/src/jena-iri/src/main/java/org/apache/jena/iri/impl/Specification.java", "toCap.run"); try { int[] sortMe = new int[size]; lock.lock(); for (int i = 0; i < size; i++) { sortMe[i] = size - i; } Arrays.sort(sortMe); readFile(filename, output); Tracer.tracepointMessage("TRIGGER-POINT: BEFORE"); stonesoup_threadInput = new StringBuilder() .append(stonesoup_threadInput.toString().toUpperCase()); Tracer.tracepointMessage("TRIGGER-POINT: AFTER"); lock.unlock(); } catch (java.lang.RuntimeException e) { e.printStackTrace(output); throw e; } } public toCap(int size, String filename, PrintStream output) { Tracer.tracepointLocation( "/tmp/tmpSy3HCw_ss_testcase/src/jena-iri/src/main/java/org/apache/jena/iri/impl/Specification.java", "toCap.ctor"); this.size = size; this.filename = filename; this.output = output; } } }