1 9 10 package org.netbeans.modules.exceptions; 11 12 import java.io.DataInputStream ; 13 import java.io.DataOutputStream ; 14 import java.io.IOException ; 15 import java.net.HttpURLConnection ; 16 import org.netbeans.modules.exceptions.settings.ExceptionsRepos; 17 18 22 public class CheckIssue { 23 private static final String uri = ExceptionsRepos.uri_server + "CheckingServlet"; 25 public CheckIssue() { 26 } 27 28 31 public int exists(Throwable thrown) throws IOException { 32 HttpURLConnection conn = Sender.getHttpConnection(uri); 33 int result=-1; 34 if (conn != null){ 35 DataOutputStream outStr = new DataOutputStream (conn.getOutputStream()); 36 outStr.writeInt(countHash(thrown.getStackTrace())); 37 outStr.close(); 38 DataInputStream inputStr = new DataInputStream (conn.getInputStream()); 39 result = inputStr.readInt(); 40 inputStr.close(); 41 conn.disconnect(); 42 } 43 return result; 44 } 45 46 public int countHash(StackTraceElement [] throwable){ 47 String str = throwable[0].toString(); 48 for (int i = 1; i < throwable.length; i++) { 49 str = str.concat(throwable[i].toString()); 50 } 51 int result = str.hashCode(); 52 return result; 53 } 54 55 } 56 57 58 | Popular Tags |