Reputation: 638
I am trying to debug my java code. I am setting a conditional break point. However when I debug it shows the error "Conditional breakpoint has compilation errors".
The following is my code snippet:
public RecipientsDTO readRecipientsFromStream(InputStream inputStream) {
ICsvListReader listReader = null;
List<Object> list;
Set<String> values = new HashSet<>();
int numberOfDuplicates = 0;
try {
listReader = new CsvListReader(new InputStreamReader(inputStream),
CsvPreference.STANDARD_PREFERENCE);
while (listReader.read() != null) {
CellProcessor[] processors;
if (listReader.length() == SINGLE_COLUMN_PROCESSOR.length) {
processors = SINGLE_COLUMN_PROCESSOR;
} else {
processors = TWO_COLUMN_PROCESSOR;
}
list = listReader.executeProcessors(processors);
String recipient = (String) list.get(0);
if (!recipient.contains("@")) {
recipient = recipient.replaceAll("[ \\-\\(\\);]", "");
}
if (!values.contains(recipient)) {
values.add(recipient);
} else {
numberOfDuplicates++;
}
}
} catch (SuperCsvConstraintViolationException e) {
log.error("Error parsing csv: {}", e.getMessage());
throw new ParsingFileException(String.format("At Line Number: %s, Message: %s",
listReader != null ? listReader.getLineNumber() : "Unknown", e.getMessage()));
} catch (Exception e) {
log.error("Error parsing csv: {}", e.getMessage());
throw new ParsingFileException();
}
return new RecipientsDTO().numbers(values).numberOfDuplicates(numberOfDuplicates);
}
this is my conditional break point.
recipient.equals("1")
However it shows that the recipient cannot be resolved:
The following is my conditional break point screenshot from the eclipse:
Upvotes: 1
Views: 758
Reputation: 44952
Conditional line break point expression is evaluated before the code reaches the line. Since recipient
is defined in line 65, you can't use this variable name in break point for line 65.
To fix it you can rewrite the line break point expression as:
"1".equals(list.get(0))
or move the break point to line 66.
Upvotes: 3