moquette-io / moquette

Java MQTT lightweight broker
http://moquette-io.github.io/moquette/
Apache License 2.0
2.27k stars 814 forks source link

The enabled by default telemetry requires deprecated `PERSISTENT_STORE_PROPERTY_NAME` constant #730

Closed dentex closed 1 year ago

dentex commented 1 year ago

Expected behavior

Be able to use DATA_PATH_PROPERTY_NAME only for the persistent store, since PERSISTENT_STORE_PROPERTY_NAME is deprecated

Actual behavior

If usage telemetry is left enabled and the only BrokerConstants.DATA_PATH_PROPERTY_NAME is used, upon server start I get:

Problem writing new UUID to file path: .moquette_uuid
java.io.FileNotFoundException: .moquette_uuid: open failed: EROFS (Read-only file system)
  at libcore.io.IoBridge.open(IoBridge.java:496)
  at java.io.FileOutputStream.<init>(FileOutputStream.java:235)
  at java.io.FileWriter.<init>(FileWriter.java:107)
  at io.moquette.broker.Server.checkOrCreateUUID(Server.java:315)
  at io.moquette.broker.Server.collectAndSendTelemetryData(Server.java:288)
  at io.moquette.broker.Server.lambda$collectAndSendTelemetryDataAsynch$0$io-moquette-broker-Server(Server.java:283)
  at io.moquette.broker.Server$$ExternalSyntheticLambda0.run(Unknown Source:4)
  at java.lang.Thread.run(Thread.java:919)
Caused by: android.system.ErrnoException: open failed: EROFS (Read-only file system)

I think this is due to the method checkOrCreateUUID(IConfig config) from Server.java, still using the deprecated constant: https://github.com/moquette-io/moquette/blob/3c53bd848fe2868823a8facbfdbb01b5efc2d909/broker/src/main/java/io/moquette/broker/Server.java#L303 This results in a filepath at the root of the filesystem, which is not writable.

I get no errors if I set both props.setProperty(BrokerConstants.PERSISTENT_STORE_PROPERTY_NAME, storePropertyName); props.setProperty(BrokerConstants.DATA_PATH_PROPERTY_NAME, storePropertyName);

Also disabling telemetry obviously works.

Steps to reproduce

declare a writable path only for BrokerConstants.DATA_PATH_PROPERTY_NAME .

Minimal yet complete reproducer code (or URL to code) or complete log file

[...]

Moquette MQTT version

0.17-SNAPSHOT @ https://github.com/moquette-io/moquette/pull/722

JVM version (e.g. java -version)

11.0.15

OS version (e.g. uname -a)

Linux localhost 4.14.175-g6f3fc9538452 #1 SMP PREEMPT Wed Apr 8 17:38:09 UTC 2020 i686

andsel commented 1 year ago

Thank's @dentex for reporting it, it's fixed in the upcoming 0.17 version