influxdata / influxdata/influxdb-java
com.squareup.moshi.JsonEncodingException: Use JsonReader.setLenient(true) to accept malformed JSON at path $
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.2k
- Forks
- 469
- PR merge metrics
- No merged PRs in 30d
Description
The code is as follows:
```java
import lombok.Getter;
import lombok.Setter;
import org.influxdb.InfluxDB;
import org.influxdb.InfluxDBFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Getter
@Setter
@Configuration
@ConfigurationProperties(prefix = "influxdb")
public class InfluxdbConfig {
private String url;
private String username;
private String password;
private String database;
@Bean
public InfluxDB influxDB() {
InfluxDB influxDB = InfluxDBFactory.connect(url, username, password);
if (!influxDB.databaseExists(database)) {
influxDB.createDatabase(database);
}
influxDB.setDatabase(database);
return influxDB;
}
}
```
The exception is as follows:
```
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'influxDB' defined in class path resource [cn/tongdun/pir/biz/config/InfluxdbConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.influxdb.InfluxDB]: Factory method 'influxDB' threw exception; nested exception is org.influxdb.InfluxDBIOException: com.squareup.moshi.JsonEncodingException: Use JsonReader.setLenient(true) to accept malformed JSON at path $
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:645)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:475)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
at cn.tongdun.pir.AppMain.main(AppMain.java:132)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.influxdb.InfluxDB]: Factory method 'influxDB' threw exception; nested exception is org.influxdb.InfluxDBIOException: com.squareup.moshi.JsonEncodingException: Use JsonReader.setLenient(true) to accept malformed JSON at path $
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:640)
... 19 more
Caused by: org.influxdb.InfluxDBIOException: com.squareup.moshi.JsonEncodingException: Use JsonReader.setLenient(true) to accept malformed JSON at path $
at org.influxdb.impl.InfluxDBImpl.execute(InfluxDBImpl.java:850)
at org.influxdb.impl.InfluxDBImpl.executeQuery(InfluxDBImpl.java:833)
at org.influxdb.impl.InfluxDBImpl.describeDatabases(InfluxDBImpl.java:759)
at org.influxdb.impl.InfluxDBImpl.databaseExists(InfluxDBImpl.java:777)
at cn.tongdun.pir.biz.config.InfluxdbConfig.influxDB(InfluxdbConfig.java:25)
at cn.tongdun.pir.biz.config.InfluxdbConfig$$EnhancerBySpringCGLIB$$80d02b94.CGLIB$influxDB$7()
at cn.tongdun.pir.biz.config.InfluxdbConfig$$EnhancerBySpringCGLIB$$80d02b94$$FastClassBySpringCGLIB$$cc601626.invoke()
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363)
at cn.tongdun.pir.biz.config.InfluxdbConfig$$EnhancerBySpringCGLIB$$80d02b94.influxDB()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
... 20 more
Caused by: com.squareup.moshi.JsonEncodingException: Use JsonReader.setLenient(true) to accept malformed JSON at path $
at com.squareup.moshi.JsonReader.syntaxError(JsonReader.java:233)
at com.squareup.moshi.JsonUtf8Reader.checkLenient(JsonUtf8Reader.java:1051)
at com.squareup.moshi.JsonUtf8Reader.doPeek(JsonUtf8Reader.java:366)
at com.squareup.moshi.JsonUtf8Reader.peek(JsonUtf8Reader.java:193)
at com.squareup.moshi.JsonAdapter$2.fromJson(JsonAdapter.java:134)
at retrofit2.converter.moshi.MoshiResponseBodyConverter.convert(MoshiResponseBodyConverter.java:46)
at retrofit2.converter.moshi.MoshiResponseBodyConverter.convert(MoshiResponseBodyConverter.java:27)
at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:243)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:204)
at org.influxdb.impl.InfluxDBImpl.execute(InfluxDBImpl.java:838)
... 34 more
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the InfluxdbConfig.influxDB() factory method and the InfluxDBImpl databaseExists(), describeDatabases(), and executeQuery() stack frames shown in the report. Reproduce the failure with the reported connection settings and inspect the response consumed by Moshi. Done means identifying the cause of the malformed response and documenting or correcting the client behavior, with a regression test if the project supports it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100