aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/sms/HttpSmsClient.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-07 07:07:25 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-07 07:07:25 -0700
commit65f9e253171dc6805127e5279b97fad05f8c4b9f (patch)
treefc3968d7c5c5c07118d4e153ece5af31371e90a5 /src/main/java/org/traccar/sms/HttpSmsClient.java
parent8eecfdcf5c59f92158a6c339d1622e0e9d67968c (diff)
downloadtrackermap-server-65f9e253171dc6805127e5279b97fad05f8c4b9f.tar.gz
trackermap-server-65f9e253171dc6805127e5279b97fad05f8c4b9f.tar.bz2
trackermap-server-65f9e253171dc6805127e5279b97fad05f8c4b9f.zip
Remove async methods
Diffstat (limited to 'src/main/java/org/traccar/sms/HttpSmsClient.java')
-rw-r--r--src/main/java/org/traccar/sms/HttpSmsClient.java32
1 files changed, 7 insertions, 25 deletions
diff --git a/src/main/java/org/traccar/sms/HttpSmsClient.java b/src/main/java/org/traccar/sms/HttpSmsClient.java
index 6234eabb8..5c3cef747 100644
--- a/src/main/java/org/traccar/sms/HttpSmsClient.java
+++ b/src/main/java/org/traccar/sms/HttpSmsClient.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2018 - 2020 Anton Tananaev (anton@traccar.org)
+ * Copyright 2018 - 2022 Anton Tananaev (anton@traccar.org)
* Copyright 2018 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,8 +16,6 @@
*/
package org.traccar.sms;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.traccar.Context;
import org.traccar.config.Keys;
import org.traccar.helper.DataConverter;
@@ -25,7 +23,6 @@ import org.traccar.notification.MessageException;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.Invocation;
-import javax.ws.rs.client.InvocationCallback;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.UnsupportedEncodingException;
@@ -34,8 +31,6 @@ import java.nio.charset.StandardCharsets;
public class HttpSmsClient implements SmsManager {
- private static final Logger LOGGER = LoggerFactory.getLogger(HttpSmsClient.class);
-
private final String url;
private final String authorizationHeader;
private final String authorization;
@@ -91,26 +86,13 @@ public class HttpSmsClient implements SmsManager {
}
@Override
- public void sendMessageSync(String destAddress, String message, boolean command) throws MessageException {
- Response response = getRequestBuilder().post(Entity.entity(preparePayload(destAddress, message), mediaType));
- if (response.getStatus() / 100 != 2) {
- throw new MessageException(response.readEntity(String.class));
- }
- }
-
- @Override
- public void sendMessageAsync(final String destAddress, final String message, final boolean command) {
- getRequestBuilder().async().post(
- Entity.entity(preparePayload(destAddress, message), mediaType), new InvocationCallback<String>() {
- @Override
- public void completed(String s) {
- }
-
- @Override
- public void failed(Throwable throwable) {
- LOGGER.warn("SMS send failed", throwable);
+ public void sendMessage(String destAddress, String message, boolean command) throws MessageException {
+ try (Response response = getRequestBuilder()
+ .post(Entity.entity(preparePayload(destAddress, message), mediaType))) {
+ if (response.getStatus() / 100 != 2) {
+ throw new MessageException(response.readEntity(String.class));
}
- });
+ }
}
}