use of org.spf4j.io.csv.CsvParseException in project spf4j by zolyfarkas.
the class RecorderFactory method buildStoreFromConfig.
/**
* Configuration is a coma separated list of stores:
* TSDB@/path/to/file.tsdb,TSDB_TXT@/path/to/file.tsdbtxt,GRAPHITE_UDP@1.1.1.1:8080,GRAPHITE_TCP@1.1.1.1:8080
*
* @param configuration
* @return a measurement store.
*/
@Nonnull
// the config is not supplied by a user.
@SuppressFBWarnings("PATH_TRAVERSAL_IN")
private static MeasurementStore buildStoreFromConfig(@Nullable final String configuration) throws IOException, ObjectCreationException {
if (configuration == null || configuration.trim().isEmpty()) {
return new TSDBMeasurementStore(new File(System.getProperty("spf4j.perf.ms.defaultTsdbFolderPath", System.getProperty("java.io.tmpdir")) + File.separator + CharSequences.validatedFileName(System.getProperty("spf4j.perf.ms.defaultTsdbFileNamePrefix", ManagementFactory.getRuntimeMXBean().getName() + ".tsdb2"))));
}
List<String> stores;
try {
stores = Csv.readRow(new StringReader(configuration));
} catch (CsvParseException ex) {
throw new IllegalArgumentException("Invalid configuration " + configuration, ex);
}
final int size = stores.size();
if (size == 1) {
return fromString(stores.get(0));
} else {
MeasurementStore[] mstores = new MeasurementStore[size];
int i = 0;
for (String config : stores) {
mstores[i] = fromString(config);
i++;
}
return new MultiStore(mstores);
}
}
use of org.spf4j.io.csv.CsvParseException in project spf4j by zolyfarkas.
the class CsvTest method testCsvReadWriteException.
@Test(expected = CsvParseException.class)
public void testCsvReadWriteException() throws IOException, CsvParseException {
File testFile = createTestCsv();
Csv.read(testFile, Charsets.UTF_8, new Csv.CsvHandler<Void>() {
@Override
public void element(final CharSequence elem) throws CsvParseException {
throw new CsvParseException("Yohooo at " + elem);
}
@Override
public Void eof() {
return null;
}
});
}
Aggregations