mirror of
https://github.com/Av0idD4rk/packmate.git
synced 2026-10-23 16:31:01 +00:00
Добавлена обработка ошибки sockjs
This commit is contained in:
parent
1e08c70a3b
commit
48397aed09
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user