[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [metrics-lib/master] Disallow reconfiguring readers after starting to read.
commit 9f13426eaefa9f1bdfca34515627ec509ae453bd
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Tue Jan 31 18:00:21 2012 +0100
Disallow reconfiguring readers after starting to read.
---
.../impl/RelayOrBridgeDescriptorReaderImpl.java | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/src/org/torproject/descriptor/impl/RelayOrBridgeDescriptorReaderImpl.java b/src/org/torproject/descriptor/impl/RelayOrBridgeDescriptorReaderImpl.java
index d33dba5..3cfb18e 100644
--- a/src/org/torproject/descriptor/impl/RelayOrBridgeDescriptorReaderImpl.java
+++ b/src/org/torproject/descriptor/impl/RelayOrBridgeDescriptorReaderImpl.java
@@ -30,22 +30,41 @@ public class RelayOrBridgeDescriptorReaderImpl
implements RelayDescriptorReader, BridgeDescriptorReader,
BridgePoolAssignmentReader {
+ private boolean hasStartedReading = false;
+
private List<File> directories = new ArrayList<File>();
public void addDirectory(File directory) {
+ if (this.hasStartedReading) {
+ throw new IllegalStateException("Reconfiguration is not permitted "
+ + "after starting to read.");
+ }
this.directories.add(directory);
}
private File historyFile;
public void setExcludeFiles(File historyFile) {
+ if (this.hasStartedReading) {
+ throw new IllegalStateException("Reconfiguration is not permitted "
+ + "after starting to read.");
+ }
this.historyFile = historyFile;
}
private boolean failUnrecognizedDescriptorLines = false;
public void setFailUnrecognizedDescriptorLines() {
+ if (this.hasStartedReading) {
+ throw new IllegalStateException("Reconfiguration is not permitted "
+ + "after starting to read.");
+ }
this.failUnrecognizedDescriptorLines = true;
}
public Iterator<DescriptorFile> readDescriptors() {
+ if (this.hasStartedReading) {
+ throw new IllegalStateException("Initiating reading is only "
+ + "permitted once.");
+ }
+ this.hasStartedReading = true;
BlockingIteratorImpl<DescriptorFile> descriptorQueue =
new BlockingIteratorImpl<DescriptorFile>();
DescriptorReader reader = new DescriptorReader(this.directories,
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits