Apostrophe in FeignException shows like /u0027 - java

I have a Feign client which I use to get information from SonarQube and when I'm trying to test request with wrong component name I have an issue with displaying apostrophes as unicode (/u0027).
Here's the test code:
void measuresSearchHistoryUnknownTest() {
assertThatExceptionOfType(FeignException.NotFound.class)
.isThrownBy(() -> sonarFeignClient.measuresSearchHistory(
"badProject",
String.join(",",
EnumUtils.getJsonValue(SonarMetric.BLOCKER_VIOLATIONS),
EnumUtils.getJsonValue(SonarMetric.CRITICAL_VIOLATIONS)
),
1,
10
)).withMessageContaining("Component key 'badProject' not found");
// )).withMessageContaining("Component key \\u0027badProject\\u0027 not found");
}
This test works only if use last line (commented line with "\u0027badProject\u0027"), but it fails if I use previous line (with common apostrophes):
Expecting throwable message:
<"[404] during [GET] to [*******/sonar/api/measures/search_history?component=badProject&metrics=blocker_violations%2Ccritical_violations&p=1&ps=10] [SonarFeignClient#measuresSearchHistory(String,String,int,int)]: [{"errors":[{"msg":"Component key \u0027badProject\u0027 not found"}]}]">
to contain:
<"Component key 'badProject' not found">
but did not.
Throwable that failed the check:
feign.FeignException$NotFound: [404] during [GET] to [*******/sonar/api/measures/search_history?component=badProject&metrics=blocker_violations%2Ccritical_violations&p=1&ps=10] [SonarFeignClient#measuresSearchHistory(String,String,int,int)]: [{"errors":[{"msg":"Component key \u0027badProject\u0027 not found"}]}]
If I look this link in a browser SonarQube shows me JSON with error message and common apostrophes (not unicode), so I think an issue somewhere in Feign.
I use "spring-cloud-starter-openfeign:3.0.1"
Maybe someone can help me with that? How can I prevent parsing of apostrophes to Unicode?

Related

Error in generating Java Wrapper in Web3j

I am trying to generate java Wrapper for a smart contract, but it failed because of this error:
Exception in thread "main" java.lang.IllegalArgumentException: not a valid name: Main.sol:main
at com.squareup.javapoet.Util.checkArgument(Util.java:64)
at com.squareup.javapoet.TypeSpec$Builder.<init>(TypeSpec.java:383)
at com.squareup.javapoet.TypeSpec$Builder.<init>(TypeSpec.java:362)
at com.squareup.javapoet.TypeSpec.classBuilder(TypeSpec.java:90)
at org.web3j.codegen.SolidityFunctionWrapper.createClassBuilder(SolidityFunctionWrapper.java:172)
at org.web3j.codegen.SolidityFunctionWrapper.generateJavaFiles(SolidityFunctionWrapper.java:103)
at org.web3j.codegen.SolidityFunctionWrapper.generateJavaFiles(SolidityFunctionWrapper.java:91)
at org.web3j.codegen.SolidityFunctionWrapperGenerator.generate(SolidityFunctionWrapperGenerator.java:123)
at org.web3j.codegen.SolidityFunctionWrapperGenerator.main(SolidityFunctionWrapperGenerator.java:87)
at org.web3j.codegen.SolidityFunctionWrapperGenerator.run(SolidityFunctionWrapperGenerator.java:48)
at org.web3j.console.Runner.main(Runner.java:38)
I followed what this guy said to remove this error
https://github.com/web3j/web3j/issues/16]
and give a default name (letters alphabetically) for each empty property as the following:
[{"constant":true,"inputs":
[{"name”:”a”,”type":"bytes32"}],"name":"ApprovedTAs","outputs":
[{"name":"Trade_id","type":"bytes32"},{"name":"Trade_producer","type":"address"},{"name":"Trade_consumer","type":"address"},{"name":"Trade_rate","type":"uint256"},{"name":"Trade_from","type":"uint256"},{"name":"Trade_to","type":"uint256"},{"name":"Trade_broker","type":"address"},{"name":"Trade_topic","type":"uint256"},{"name":"approvedByA","type":"bool"},{"name":"approvedByB","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name”:”b”,”type":"address"},{"name”:”c”,”type":"uint256"}],"name":"offersByProducer","outputs":[{"name":"offer_id","type":"uint256"},{"name":"offer_producer","type":"address"},{"name":"offer_topic","type":"uint256"},{"name":"offer_rate","type":"uint256"},{"name":"offer_from","type":"uint256"},{"name":"offer_to","type":"uint256"},{"name":"offer_broker","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"getAll","outputs":[{"name”:”d”,”type":"address[]"},{"name”:”e”,”type":"address[]"},{"name”:”f”,”type":"address[]"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"mk_producer","type":"address"},{"name":"mk_topic","type":"uint256"},{"name":"mk_rate","type":"uint256"},{"name":"mk_from","type":"uint256"},{"name":"mk_to","type":"uint256"},{"name":"mk_broker","type":"address"}],"name":"mkOrder","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name”:”g”,”type":"uint256"}],"name":"offers","outputs":[{"name":"offer_id","type":"uint256"},{"name":"offer_producer","type":"address"},{"name":"offer_topic","type":"uint256"},{"name":"offer_rate","type":"uint256"},{"name":"offer_from","type":"uint256"},{"name":"offer_to","type":"uint256"},{"name":"offer_broker","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"ofr_topic","type":"uint256"},{"name":"ofr_rate","type":"uint256"},{"name":"ofr_from","type":"uint256"},{"name":"ofr_to","type":"uint256"},{"name":"ofr_broker","type":"address"}],"name":"offer","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name”:”h”,”type":"uint256"},{"name”:”ii”,”type":"uint256"}],"name":"allAdd","outputs":[{"name”:”j”,”type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"sndC_id","type":"bytes32"},{"name":"sndC_producer","type":"address"},{"name":"sndC_broker","type":"address"},{"name":"sndC_topic","type":"uint256"},{"name":"sndC_from","type":"uint256"},{"name":"sndC_to","type":"uint256"},{"name":"sndC_count","type":"uint256"}],"name":"sendCCube","outputs":[{"name”:”l”,”type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"id","type":"bytes32"}],"name":"agreeTA","outputs":[{"name”:”m”,”type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"sndP_id","type":"bytes32"},{"name":"sndP_broker","type":"address"},{"name":"sndP_topic","type":"uint256"},{"name":"sndP_from","type":"uint256"},{"name":"sndP_to","type":"uint256"},{"name":"sndP_count","type":"uint256"}],"name":"sendPCube","outputs":[{"name”:”n”,”type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name”:”o”,”type":"bytes32"}],"name":"CreatedTAs","outputs":[{"name":"Trade_id","type":"bytes32"},{"name":"Trade_producer","type":"address"},{"name":"Trade_consumer","type":"address"},{"name":"Trade_rate","type":"uint256"},{"name":"Trade_from","type":"uint256"},{"name":"Trade_to","type":"uint256"},{"name":"Trade_broker","type":"address"},{"name":"Trade_topic","type":"uint256"},{"name":"approvedByA","type":"bool"},{"name":"approvedByB","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"nkname","type":"string"},{"name":"code","type":"uint256"}],"name":"register","outputs": [{"name”:”p”,”type":"bool"}],"payable":false,"type":"function"}]
But the error still the same. I also changed the name of the contract rather than "main" but nothing change.
I also changed every variable name has numbers, special characters or even starting with _ but still doesn't work.
Any idea what I should change to solve this error
Thanks
This error is triggered if you are declaring a function o event with only the argument type without a name.for example :
event myevent(string)
should be
event myevent(string message);

Cloud vision api text detection showing syntax errors

I have downloaded Java Vision API project from Github.
I enabled billing for my project through developers console and got client_secret for my project. Later by adding an environment variable GOOGLE_APPLICATION_CREDENTIALS pointing to my client_secret file. I'm able to do all the other operations like Labeling, face detection and Landmark detection. When I try to execute text_detection code I'm getting these errors. See Image here
public void indexDirectory(Path inputPath) throws IOException {
List<Path> unprocessedImages =
Files.walk(inputPath)
.filter(Files::isRegularFile)
.filter(index::isDocumentUnprocessed)
.collect(Collectors.toList());
Lists.<Path>partition(unprocessedImages, BATCH_SIZE)
.stream()
.map(this::detectText)
.flatMap(l -> l.stream())
.filter(this::successfullyDetectedText)
.map(this::extractDescriptions)
.forEach(index::addDocument);}
This is the code I've written and I'm getting the below errors.
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Files cannot be resolved to a variable
Syntax error on tokens, delete these tokens
Syntax error on tokens, delete these tokens
Syntax error on token(s), misplaced construct(s)
Syntax error on tokens, delete these tokens
Syntax error on token "-", -- expected
Syntax error on tokens, delete these tokens
Syntax error on tokens, delete these tokens
Syntax error on token ":", EnhancedForStatementHeaderInit expected after this token
at com.google.cloud.vision.samples.text.TextApp.indexDirectory(TextApp.java:158)
at com.google.cloud.vision.samples.text.TextApp.main(TextApp.java:107)
I know that these are syntax error but still I'm unable to find any solution to make it work.
Can anyone please suggest me how I can get this to work.

What is the maximum size of file that Jackson Csv to Json library can handle?

I am using Jackson to convert a csv file to json. However I get the following exception:
Exception in thread "main" com.fasterxml.jackson.core.JsonParseException: Too many entries: expected at most 71 (value #71 (0 chars) "")
at [Source: com.fasterxml.jackson.dataformat.csv.impl.UTF8Reader#5f83bcb8; line: 149, column: 1153]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1487)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:518)
at com.fasterxml.jackson.dataformat.csv.CsvParser._handleNextEntryExpectEOL(CsvParser.java:643)
at com.fasterxml.jackson.dataformat.csv.CsvParser._handleNextEntry(CsvParser.java:629)
at com.fasterxml.jackson.dataformat.csv.CsvParser.nextToken(CsvParser.java:472)
at com.fasterxml.jackson.databind.deser.std.MapDeserializer._readAndBindStringMap(MapDeserializer.java:470)
at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:342)
at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:26)
at com.fasterxml.jackson.databind.MappingIterator.nextValue(MappingIterator.java:188)
at com.fasterxml.jackson.databind.MappingIterator.readAll(MappingIterator.java:226)
at com.fasterxml.jackson.databind.MappingIterator.readAll(MappingIterator.java:212)
at CsvToJsonParser.readObjectsFromCsv(CsvToJsonParser.java:47)
at CsvToJsonParser.convertCsvToJson(CsvToJsonParser.java:36)
at MainParser.main(MainParser.java:16)
I noticed that I am getting this exception when I have a file with more than ~70 entries. However I want to convert a file with ~60000 entries!!!
Anybody has an idea what causes the limitation to the Jackson library??
Others have commented on misunderstanding wrt error message; but to be precise, error message indicates that there is an extra value on specified row. Looking at additional value (empty String), I am guessing you simply have an extra comma at the end of that line.

HtmlUnit generates warning for invalid css

We are using htmlunit for our functioal test and it works very well. One of the issue I have seen is in build, it generates some warning messages:
ERROR [main] (StrictErrorReporter.java:80) - runtimeError: message=[An
invalid or illegal selector was specified (selector: '.page-container
.order-completed-selector[data-product-number=0022002]' error: Invalid
selectors: .page-container
.order-completed-selector[data-product-number=0022002]).]
sourceName=[http://localhost/resources/scripts/lib/jquery-1.7.2.js]
line=[5138] lineSource=[null] lineOffset=[0]
I am not sure what is the exact reason since it works fine at browser level and tests also pass. But it looks to me that it doesn't like attribute [data-product-number=0022002]. Does anybody know what can be the reason for the same?
You need to put the number into quotes:
[data-product-number='0022002']
(I think both, " and ' should be correct by CSS specification.)

Java Exception appends ": null" to "Caused by" clause

There are some exceptions shown as follows in my log: (the text has been modified to conceal project information)
java.util.concurrent.ExecutionException:org.xxx.BBBException<br>
at ....<br>
...<br>
Caused by: org.xxx.BBBException: null<br>
at ....<br>
...<br>
Why is there "null" in the Caused by clause?
BBBException, which was made by us, extends Exception and does not override toString().
In some situations, FutureTask.setException(new BBBException("RPC timed out")) is called and BBBException is being expected in the log.
However, the exception's details message is not what we set in the program and the text in the first line and Caused by clause even do not match (there is no ": null" in the first line).
Anyone has a clue why this has happened? Thanks!
Environment: java 6, update 21, centos 64-bit, java 64-bit, mixed mode.
I suspect you've either actually created a new BBBException without a message, or your BBBException(String) constructor doesn't pass the message up to the super-constructor (which it should, via super(message)). Basically it's saying: this is an exception with no message.
It's hard to tell exactly what's wrong without seeing any of your code though.
org.xxx.BBBException: null was thrown with null message (using default constructor). Throw it with some message (if it supports it):
throw new BBBException("Danger! High Voltage")
If this doesn't work, it means the BBBException(String msg) constructor is poorly written. It should be something like:
BBBException(String msg) {
super(msg);
}

Categories

Resources