Compare commits

...

7 Commits

Author SHA1 Message Date
Andrea Cavalli
7271ceca8d Update logging 2022-01-04 12:59:33 +01:00
Andrea Cavalli
2c798cc91b Remove incremental compilation flag from maven 2021-12-30 17:27:15 +01:00
Andrea Cavalli
cc06ee3fa2 Update log4j 2021-12-17 16:26:44 +01:00
Andrea Cavalli
06ffdabcab Update reactor 2021-12-17 01:49:36 +01:00
Andrea Cavalli
d2267963c8 Fix compilation issues 2021-12-16 16:46:14 +01:00
Andrea Cavalli
049a230fae Code cleanup 2021-12-16 16:34:43 +01:00
Andrea Cavalli
e54278d38d Update tdlib 2021-12-08 15:40:09 +01:00
12 changed files with 57 additions and 69 deletions

41
pom.xml
View File

@ -9,16 +9,16 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>0-SNAPSHOT</revision>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<vertx.version>4.2.0</vertx.version>
<vertx.version>4.2.2</vertx.version>
</properties>
<repositories>
<repository>
<id>protoarch</id>
<name>protoarch</name>
<url>http://home.apache.org/~aajisaka/repository</url>
<url>https://home.apache.org/~aajisaka/repository</url>
</repository>
<repository>
<id>mchv-release</id>
@ -65,8 +65,10 @@
</dependency>
<dependency>
<groupId>it.tdlight</groupId>
<artifactId>tdlight-java</artifactId>
<version>2.7.9.2</version>
<artifactId>tdlight-java-bom</artifactId>
<version>1.0.0.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
@ -95,7 +97,7 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.1</version>
<version>5.8.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
@ -107,7 +109,7 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.1</version>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
@ -118,47 +120,37 @@
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.4.11</version>
<version>3.4.13</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-tools</artifactId>
<version>3.4.11</version>
<version>3.4.13</version>
</dependency>
<dependency>
<groupId>io.projectreactor.addons</groupId>
<artifactId>reactor-adapter</artifactId>
<version>3.4.5</version>
<version>3.4.6</version>
</dependency>
<dependency>
<groupId>com.akaita.java</groupId>
<artifactId>rxjava2-debug</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.32</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.14.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.14.1</version>
<version>2.17.0</version>
</dependency>
<dependency>
<groupId>org.warp</groupId>
<artifactId>common-utils</artifactId>
<version>1.1.5</version>
<version>1.1.7</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>2.0.45.Final</version>
<version>2.0.46.Final</version>
</dependency>
<dependency>
@ -225,7 +217,6 @@
<version>3.8.1</version>
<configuration>
<release>11</release>
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration>
</plugin>
<plugin>

View File

@ -25,9 +25,8 @@ import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.Nullable;
import org.warp.commonutils.log.Logger;
import org.warp.commonutils.log.LoggerFactory;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.publisher.Sinks;
@ -37,7 +36,7 @@ import reactor.tools.agent.ReactorDebugAgent;
public class TDLibRemoteClient implements AutoCloseable {
private static final Logger logger = LoggerFactory.getLogger(TDLibRemoteClient.class);
private static final Logger logger = LogManager.getLogger(TDLibRemoteClient.class);
@Nullable
private final SecurityInfo securityInfo;

View File

@ -14,8 +14,8 @@ import it.tdlight.utils.MonoUtils;
import java.time.Duration;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;
import org.warp.commonutils.log.Logger;
import org.warp.commonutils.log.LoggerFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.publisher.Sinks;
@ -24,7 +24,7 @@ import reactor.core.scheduler.Schedulers;
public class AsyncTdDirectImpl implements AsyncTdDirect {
private static final Logger logger = LoggerFactory.getLogger(AsyncTdDirect.class);
private static final Logger logger = LogManager.getLogger(AsyncTdDirect.class);
private final TelegramClientFactory telegramClientFactory;
private final JsonObject implementationDetails;

View File

@ -30,9 +30,9 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.Nullable;
import org.warp.commonutils.log.Logger;
import org.warp.commonutils.log.LoggerFactory;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.publisher.Sinks;
@ -40,7 +40,7 @@ import reactor.core.publisher.Sinks.Empty;
public class TestClient implements ReactorTelegramClient {
private static final Logger logger = LoggerFactory.getLogger(TestClient.class);
private static final Logger logger = LogManager.getLogger(TestClient.class);
private static final AtomicLong incrementalMessageId = new AtomicLong(1);
private final List<String> features;
@ -57,7 +57,7 @@ public class TestClient implements ReactorTelegramClient {
private static Message generateRandomMessage(boolean randomSender, boolean randomChat, boolean randomText) {
var msg = new Message();
msg.sender = new MessageSenderUser(312042);
msg.senderId = new MessageSenderUser(312042);
msg.chatId = 240213;
msg.id = incrementalMessageId.getAndIncrement();
var content = new MessageText();

View File

@ -45,10 +45,9 @@ import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.reactivestreams.Publisher;
import org.warp.commonutils.log.Logger;
import org.warp.commonutils.log.LoggerFactory;
import org.warp.commonutils.error.InitializationException;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.publisher.Sinks;
@ -76,11 +75,11 @@ public class AsyncTdEasy {
public AsyncTdEasy(AsyncTdMiddle td, String logName) {
this.td = td;
this.logName = logName;
this.logger = LoggerFactory.getLogger("AsyncTdEasy " + logName);
this.logger = LogManager.getLogger("AsyncTdEasy " + logName);
this.incomingUpdates = td.receive()
.flatMapSequential(this::preprocessUpdates)
.flatMapSequential(update -> Mono.from(this.getState()).single().map(state -> new AsyncTdUpdateObj(state, update)))
.flatMapSequential(update -> Mono.from(this.state()).single().map(state -> new AsyncTdUpdateObj(state, update)))
.map(upd -> (TdApi.Update) upd.getUpdate())
.doOnError(ex -> {
if (ex instanceof TdError) {
@ -136,7 +135,7 @@ public class AsyncTdEasy {
try {
Files.createDirectories(Path.of(settings.databaseDirectory));
} catch (IOException ex) {
throw new InitializationException(ex);
throw new IllegalStateException(ex);
}
}
@ -156,7 +155,7 @@ public class AsyncTdEasy {
/**
* Get TDLib state
*/
public Flux<AuthorizationState> getState() {
public Flux<AuthorizationState> state() {
return authState.asFlux().distinct();
}
@ -323,7 +322,7 @@ public class AsyncTdEasy {
* Closes the client gracefully by sending {@link TdApi.Close}.
*/
public Mono<Void> close() {
return Mono.from(getState())
return Mono.from(state())
.filter(state -> {
switch (state.getConstructor()) {
case AuthorizationStateClosing.CONSTRUCTOR:
@ -438,7 +437,7 @@ public class AsyncTdEasy {
return thenOrFatalError(Mono.fromCallable(this.settings::get).single().flatMap(settings -> {
if (settings.isPhoneNumberSet()) {
return sendDirectly(new SetAuthenticationPhoneNumber(String.valueOf(settings.getPhoneNumber()),
new PhoneNumberAuthenticationSettings(false, false, false)
new PhoneNumberAuthenticationSettings(false, false, false, false, null)
), false);
} else if (settings.isBotTokenSet()) {
return sendDirectly(new CheckAuthenticationBotToken(settings.getBotToken()), false);
@ -550,6 +549,7 @@ public class AsyncTdEasy {
.filterWhen(file -> Mono
.fromCallable(() -> Files.exists(file))
.subscribeOn(Schedulers.boundedElastic()))
.publishOn(Schedulers.boundedElastic())
.doOnNext(directory -> {
try {
if (!Files.walk(directory)

View File

@ -29,9 +29,9 @@ import java.nio.file.Path;
import java.time.Duration;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.LockSupport;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.warp.commonutils.locks.LockUtils;
import org.warp.commonutils.log.Logger;
import org.warp.commonutils.log.LoggerFactory;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.publisher.Sinks;
@ -71,7 +71,7 @@ public class AsyncTdMiddleEventBusClient implements AsyncTdMiddle {
private boolean local;
public AsyncTdMiddleEventBusClient(TdClusterManager clusterManager) {
this.logger = LoggerFactory.getLogger(AsyncTdMiddleEventBusClient.class);
this.logger = LogManager.getLogger(AsyncTdMiddleEventBusClient.class);
this.cluster = clusterManager;
this.deliveryOptions = cluster.newDeliveryOpts().setLocalOnly(local);
this.deliveryOptionsWithTimeout = cluster.newDeliveryOpts().setLocalOnly(local).setSendTimeout(30000);
@ -100,7 +100,7 @@ public class AsyncTdMiddleEventBusClient implements AsyncTdMiddle {
.flatMap(binlog -> binlog
.getLastModifiedTime()
.filter(modTime -> modTime == 0)
.doOnNext(v -> LoggerFactory
.doOnNext(v -> LogManager
.getLogger(AsyncTdMiddleEventBusClient.class)
.error("Can't retrieve binlog of bot " + botId + " " + botAlias + ". Creating a new one..."))
.thenReturn(binlog)).<AsyncTdMiddle>flatMap(binlog -> instance
@ -133,7 +133,7 @@ public class AsyncTdMiddleEventBusClient implements AsyncTdMiddle {
this.botAlias = botAlias;
this.botAddress = "bots.bot." + this.botId;
this.local = local;
this.logger = LoggerFactory.getLogger(this.botId + " " + botAlias);
this.logger = LogManager.getLogger(this.botId + " " + botAlias);
return MonoUtils
.fromBlockingEmpty(() -> {
EmitResult result;

View File

@ -18,8 +18,8 @@ import it.tdlight.tdlibsession.td.middle.TdClusterManager;
import it.tdlight.utils.MonoUtils;
import java.time.Duration;
import java.util.concurrent.atomic.AtomicReference;
import org.warp.commonutils.log.Logger;
import org.warp.commonutils.log.LoggerFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import reactor.core.Disposable;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@ -29,7 +29,7 @@ import reactor.core.scheduler.Schedulers;
public class AsyncTdMiddleDirect extends AbstractVerticle implements AsyncTdMiddle {
private static final Logger logger = LoggerFactory.getLogger(AsyncTdMiddleDirect.class);
private static final Logger logger = LogManager.getLogger(AsyncTdMiddleDirect.class);
private final TelegramClientFactory clientFactory;

View File

@ -15,7 +15,6 @@ import it.tdlight.utils.MonoUtils;
import java.nio.file.Path;
import java.time.Duration;
import java.util.concurrent.atomic.AtomicReference;
import org.warp.commonutils.error.InitializationException;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.publisher.Sinks;
@ -65,7 +64,7 @@ public class AsyncTdMiddleLocal implements AsyncTdMiddle {
.getT1()
.start(botId, botAlias, true, implementationDetails, tuple.getT2())
.thenReturn(tuple.getT1()))
.onErrorMap(InitializationException::new)
.onErrorMap(IllegalStateException::new)
.doOnNext(this.cli::set)
.doOnError(this.startError::set)
.thenReturn(this);

View File

@ -31,8 +31,8 @@ import java.time.Duration;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;
import org.warp.commonutils.log.Logger;
import org.warp.commonutils.log.LoggerFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
@ -41,7 +41,7 @@ import reactor.util.function.Tuples;
public class AsyncTdMiddleEventBusServer extends AbstractVerticle {
// Static values
protected static final Logger logger = LoggerFactory.getLogger("TdMiddleServer");
protected static final Logger logger = LogManager.getLogger("TdMiddleServer");
public static final byte[] EMPTY = new byte[0];
public static final Duration WAIT_DURATION = Duration.ofSeconds(1);

View File

@ -4,14 +4,14 @@ import io.vertx.core.file.OpenOptions;
import io.vertx.reactivex.core.buffer.Buffer;
import io.vertx.reactivex.core.file.AsyncFile;
import io.vertx.reactivex.core.file.FileProps;
import io.vertx.reactivex.core.file.FileSystem;
import org.warp.commonutils.log.Logger;
import org.warp.commonutils.log.LoggerFactory;
import io.vertx.reactivex.core.file.FileSystem;;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import reactor.core.publisher.Mono;
public class BinlogAsyncFile {
private static final Logger logger = LoggerFactory.getLogger(BinlogAsyncFile.class);
private static final Logger logger = LogManager.getLogger(BinlogAsyncFile.class);
private final FileSystem filesystem;
private final String path;

View File

@ -15,8 +15,8 @@ import java.text.StringCharacterIterator;
import java.time.Duration;
import java.time.Instant;
import java.time.ZoneOffset;
import org.warp.commonutils.log.Logger;
import org.warp.commonutils.log.LoggerFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
@ -25,7 +25,7 @@ import reactor.util.function.Tuples;
public class BinlogUtils {
private static final Logger logger = LoggerFactory.getLogger(BinlogUtils.class);
private static final Logger logger = LogManager.getLogger(BinlogUtils.class);
public static Mono<BinlogAsyncFile> retrieveBinlog(FileSystem vertxFilesystem, Path binlogPath) {
var path = binlogPath.toString();

View File

@ -9,7 +9,7 @@ import io.vertx.core.AsyncResult;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.Promise;
import io.vertx.reactivex.core.eventbus.Message;
import io.vertx.reactivex.core.eventbus.Message;
import io.vertx.reactivex.core.eventbus.MessageConsumer;
import io.vertx.reactivex.core.streams.Pipe;
import io.vertx.reactivex.core.streams.ReadStream;
@ -27,14 +27,13 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import java.util.function.Supplier;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscription;
import org.warp.commonutils.concurrency.future.CompletableFutureUtils;
import org.warp.commonutils.functional.IOConsumer;
import org.warp.commonutils.log.Logger;
import org.warp.commonutils.log.LoggerFactory;
import reactor.core.CoreSubscriber;
import reactor.core.publisher.Flux;
import reactor.core.publisher.FluxSink.OverflowStrategy;
@ -54,7 +53,7 @@ import reactor.util.context.Context;
public class MonoUtils {
private static final Logger logger = LoggerFactory.getLogger(MonoUtils.class);
private static final Logger logger = LogManager.getLogger(MonoUtils.class);
public static <T> Mono<T> notImplemented() {
return Mono.fromCallable(() -> {