[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r23763 - in gnunet-java: . src/org/gnunet/construct src/org
From: |
gnunet |
Subject: |
[GNUnet-SVN] r23763 - in gnunet-java: . src/org/gnunet/construct src/org/gnunet/util test/org/gnunet/util |
Date: |
Thu, 13 Sep 2012 12:22:06 +0200 |
Author: dold
Date: 2012-09-13 12:22:06 +0200 (Thu, 13 Sep 2012)
New Revision: 23763
Modified:
gnunet-java/ISSUES
gnunet-java/build.gradle
gnunet-java/src/org/gnunet/construct/MsgMap.txt
gnunet-java/src/org/gnunet/util/Configuration.java
gnunet-java/src/org/gnunet/util/Connection.java
gnunet-java/src/org/gnunet/util/Scheduler.java
gnunet-java/src/org/gnunet/util/Service.java
gnunet-java/test/org/gnunet/util/ClientServerTest.java
Log:
fixed build.gradle, started fixing bugs from coverty
Modified: gnunet-java/ISSUES
===================================================================
--- gnunet-java/ISSUES 2012-09-13 09:25:55 UTC (rev 23762)
+++ gnunet-java/ISSUES 2012-09-13 10:22:06 UTC (rev 23763)
@@ -225,4 +225,24 @@
* regarding arm:
* I understand that it's not wise to kill non-cooperating services after a
timeout
- * but shouldn't arm respond to CTRL+C in those cases? bug? intentional /
related to signal handling?
\ No newline at end of file
+ * but shouldn't arm respond to CTRL+C in those cases? bug? intentional /
related to signal handling?
+
+
+-------------------------------------------------------
+
+* gradle build script
+ * now handles the "instrument" task correctly
+ * can run the annotation processor ("msgtypes")
+ * => should we keep/maintain the old build scripts or not?
+
+
+* http://docs.oracle.com/javase/1.4.2/docs/api/java/nio/channels/Pipe.html
+ * "Many pipe implementations will buffer up to a certain number of bytes
between the sink and source channels"
+ * reminds me of matthias' problems last monday. what to do about it?
+
+
+* while revisiting the config API
+ * what encoding are config files in? utf-8, i assume?
+ * in general, when do we want gnunet-java to crash (=uncatched exception)
+ * currently: on definite programmer's error, e.g. in Construct, when an
annotation is just wrong
+ * i tried working with a small buffer in the call to read(...)
Modified: gnunet-java/build.gradle
===================================================================
--- gnunet-java/build.gradle 2012-09-13 09:25:55 UTC (rev 23762)
+++ gnunet-java/build.gradle 2012-09-13 10:22:06 UTC (rev 23763)
@@ -1,10 +1,7 @@
/*
-in-progess buildfile for gradle (http://gradle.org/)
-problems with gradle: no direct support for cobertura
+ buildfile for gradle (http://gradle.org/)
*/
-import groovy.io.FileType
-
apply plugin: 'java'
buildDir = "$projectDir/build-gradle"
@@ -13,6 +10,8 @@
compile fileTree(dir: 'lib', include: '*.jar')
}
+
+
sourceSets {
main {
java {
@@ -29,40 +28,57 @@
}
}
+compileJava.options.debugOptions.debugLevel = "source,lines,vars"
-task(instrument, dependsOn: 'compileJava', type: JavaExec) {
- //inputs.dir compileJava.destinationDir
- //outputs.dir (new File("$buildDir/classes_instrumented"))
- classpath = files("$projectDir/cobertura/cobertura.jar",
- "$projectDir/cobertura/lib/*")
+project.ext.instrumentDir = "$buildDir/classes_instrumented"
+project.ext.coberturaDir = "$projectDir/cobertura"
+project.ext.coverageData = "$projectDir/coverage.data"
+project.ext.coverageReportDir = "$projectDir/coverage-report"
+
+task instrument (dependsOn: 'compileJava', type: JavaExec) {
+ inputs.dir compileJava.destinationDir
+ outputs.dir fileTree(dir: instrumentDir)
+
+ classpath = files("$coberturaDir/cobertura.jar", "$coberturaDir/lib/*")
main = 'net.sourceforge.cobertura.instrument.Main'
- List<String> myArgs = []
- myArgs.addAll(["--datafile", "$projectDir/coverage.data"])
- myArgs.addAll(["--destination", "$buildDir/classes_instrumented/"])
+ args "--datafile", "$coverageData"
+ args "--destination", "$instrumentDir"
+}
+instrument.doFirst() {
FileTree tree = fileTree(dir: "$buildDir/classes/main/")
+ tree.visit { element ->
+ args "$buildDir/classes/main/$element.path"
+ }
+}
- tree.visit { element -> myArgs.add("$buildDir/classes/main/$element.path") }
- args myArgs
-}
-
-task(testCoverage, dependsOn: ['instrument', 'cleanTest'], type: Test) {
- classpath = files("$buildDir/classes_instrumented",
- "$projectDir/cobertura/cobertura.jar",
+task testCoverage (dependsOn: ['instrument', 'cleanTest'], type: Test) {
+ classpath = files("$instrumentDir",
+ "$coberturaDir/cobertura.jar",
project.sourceSets.test.runtimeClasspath)
- systemProperties =
["net.sourceforge.cobertura.datafile":"$projectDir/coverage.data"]
+ systemProperties = ["net.sourceforge.cobertura.datafile":"$coverageData"]
}
-task(reportCoverage, dependsOn: ['testCoverage'], type: JavaExec) {
+task reportCoverage (dependsOn: ['testCoverage'], type: JavaExec) {
classpath = files("$projectDir/cobertura/cobertura.jar",
"$projectDir/cobertura/lib/*")
main = 'net.sourceforge.cobertura.reporting.Main'
- List<String> myArgs = []
- myArgs.addAll(["--datafile", "$projectDir/coverage.data"])
- myArgs.addAll(["--destination", "$projectDir/coverage-report"])
- myArgs.add("$projectDir/src/")
- args = myArgs
+ args "--datafile", "$coverageData"
+ args "--destination", "$coverageReportDir"
+ args "$projectDir/src/"
}
+
+/*
+TODO: should we really use the compile task for this?
+*/
+task msgtypes (type: Compile) {
+ classpath = project.sourceSets.main.runtimeClasspath
+ source = files(project.sourceSets.main.allJava)
+ options.setCompilerArgs(["-processor",
"org.gnunet.construct.MessageIdAnnotationProcessor",
+ "-proc:only",
+ "-s", "src"])
+ destinationDir = file("$buildDir/classes/main/")
+}
Modified: gnunet-java/src/org/gnunet/construct/MsgMap.txt
===================================================================
--- gnunet-java/src/org/gnunet/construct/MsgMap.txt 2012-09-13 09:25:55 UTC
(rev 23762)
+++ gnunet-java/src/org/gnunet/construct/MsgMap.txt 2012-09-13 10:22:06 UTC
(rev 23763)
@@ -37,4 +37,4 @@
org.gnunet.util.GnunetMessage$Body|168=org.gnunet.statistics.SetMessage
org.gnunet.util.GnunetMessage$Body|173=org.gnunet.statistics.WatchResponseMessage
org.gnunet.util.GnunetMessage$Body|172=org.gnunet.statistics.WatchMessage
-# generated 2012/09/10 00:26:15
+# generated 2012/09/12 20:26:38
Modified: gnunet-java/src/org/gnunet/util/Configuration.java
===================================================================
--- gnunet-java/src/org/gnunet/util/Configuration.java 2012-09-13 09:25:55 UTC
(rev 23762)
+++ gnunet-java/src/org/gnunet/util/Configuration.java 2012-09-13 10:22:06 UTC
(rev 23763)
@@ -20,6 +20,7 @@
package org.gnunet.util;
+import com.google.common.base.Charsets;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
import com.google.common.io.Files;
@@ -322,17 +323,19 @@
* @param filename where to write the configuration
*/
public void write(String filename) throws IOException {
- BufferedWriter w = new BufferedWriter(new FileWriter(new File(
- filename)));
- for (String section : sections.rowKeySet()) {
- w.write("["+section+"]");
- w.newLine();
- for (Map.Entry<String,String> e :
sections.row(section).entrySet()) {
- w.write(e.getKey() + " = " + e.getValue());
+ BufferedWriter w = Files.newWriter(new File(filename), Charsets.UTF_8);
+ try {
+ for (String section : sections.rowKeySet()) {
+ w.write("["+section+"]");
w.newLine();
+ for (Map.Entry<String,String> e :
sections.row(section).entrySet()) {
+ w.write(e.getKey() + " = " + e.getValue());
+ w.newLine();
+ }
}
+ } finally {
+ w.close();
}
- w.close();
}
Modified: gnunet-java/src/org/gnunet/util/Connection.java
===================================================================
--- gnunet-java/src/org/gnunet/util/Connection.java 2012-09-13 09:25:55 UTC
(rev 23762)
+++ gnunet-java/src/org/gnunet/util/Connection.java 2012-09-13 10:22:06 UTC
(rev 23763)
@@ -105,9 +105,25 @@
private Continuation notifyConnectedContinuation;
- private class AddressProbe {
+ /**
+ * An address probe is a connection to a socket that may succeed or not.
+ * The first address probe that succeeded is used for this connection.
+ */
+ private static class AddressProbe {
Cancelable connectTask;
SocketChannel channel;
+ public void cancel() {
+ if (connectTask != null) {
+ connectTask.cancel();
+ }
+ if (channel != null) {
+ try {
+ channel.close();
+ } catch (IOException e) {
+ // nothing we can do here
+ }
+ }
+ }
}
/**
@@ -642,7 +658,7 @@
}
if (connectionChannel != null) {
try {
- connectionChannel.socket().close();
+ connectionChannel.close();
} catch (IOException e) {
throw new IOError(e);
}
Modified: gnunet-java/src/org/gnunet/util/Scheduler.java
===================================================================
--- gnunet-java/src/org/gnunet/util/Scheduler.java 2012-09-13 09:25:55 UTC
(rev 23762)
+++ gnunet-java/src/org/gnunet/util/Scheduler.java 2012-09-13 10:22:06 UTC
(rev 23763)
@@ -569,22 +569,35 @@
throw new IOError(e);
}
- ByteBuffer buffer = ByteBuffer.allocate(256);
+ // we have such a small buffer so that the pipe will not buffer
+ ByteBuffer buffer = ByteBuffer.allocate(1);
boolean quit = false;
- try {
- while (!quit) {
+ while (!quit) {
+ try {
buffer.clear();
-
fileChannel.read(buffer);
-
buffer.flip();
-
pipe.sink().write(buffer);
+ } catch (IOException e) {
+ quit = true;
+ try {
+ fileChannel.close();
+ } catch (IOException ex) {
+ // nothing we can do here
+ }
+ try {
+ pipe.sink().close();
+ } catch (IOException ex) {
+ // nothing we can do here
+ }
+ try {
+ pipe.source().close();
+ } catch (IOException ex) {
+ // nothing we can do here
+ }
}
- } catch (IOException e) {
- quit = true;
}
}
Modified: gnunet-java/src/org/gnunet/util/Service.java
===================================================================
--- gnunet-java/src/org/gnunet/util/Service.java 2012-09-13 09:25:55 UTC
(rev 23762)
+++ gnunet-java/src/org/gnunet/util/Service.java 2012-09-13 10:22:06 UTC
(rev 23763)
@@ -150,8 +150,8 @@
sigpipeChannel.close();
} catch (IOException e) {
logger.error("could not close sigpipe channel, quitting");
- System.exit(2);
}
+ System.exit(2);
}
}
}
Modified: gnunet-java/test/org/gnunet/util/ClientServerTest.java
===================================================================
--- gnunet-java/test/org/gnunet/util/ClientServerTest.java 2012-09-13
09:25:55 UTC (rev 23762)
+++ gnunet-java/test/org/gnunet/util/ClientServerTest.java 2012-09-13
10:22:06 UTC (rev 23763)
@@ -8,7 +8,11 @@
import org.junit.Assert;
import org.junit.Test;
+import java.io.IOException;
import java.net.*;
+import java.nio.ByteBuffer;
+import java.nio.channels.Pipe;
+import java.nio.channels.spi.SelectorProvider;
import java.util.ArrayList;
/**
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r23763 - in gnunet-java: . src/org/gnunet/construct src/org/gnunet/util test/org/gnunet/util,
gnunet <=