Добавлена обработка ошибки sockjs

This commit is contained in:
serega6531
2019-05-12 03:51:11 +03:00
parent 1e08c70a3b
commit 48397aed09
2 changed files with 10 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ import ru.serega6531.packmate.repository.PatternRepository;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
@Service
@@ -47,7 +48,12 @@ public class PatternService {
}
public void deleteById(int id) {
repository.deleteById(id);
final Optional<Pattern> optional = repository.findById(id);
if(optional.isPresent()) {
final Pattern pattern = optional.get();
log.info("Удален паттерн {} со значением {}", pattern.getName(), pattern.getValue());
repository.delete(pattern);
}
}
public Pattern save(Pattern pattern) {
@@ -55,7 +61,7 @@ public class PatternService {
return repository.save(pattern);
}
public java.util.regex.Pattern compilePattern(Pattern pattern) {
private java.util.regex.Pattern compilePattern(Pattern pattern) {
return compiledPatterns.computeIfAbsent(pattern.getValue(), java.util.regex.Pattern::compile);
}

View File

@@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.sockjs.SockJsTransportFailureException;
import ru.serega6531.packmate.model.Stream;
import java.io.IOException;
@@ -40,7 +41,7 @@ public class StreamSubscriptionService {
subscribers.forEach(s -> {
try {
s.sendMessage(objectToTextMessage(stream));
} catch (IOException e) {
} catch (IOException | SockJsTransportFailureException e) {
e.printStackTrace();
}
});