Skip to content

Commit

Permalink
spring-retry
Browse files Browse the repository at this point in the history
  • Loading branch information
nixel2007 committed Aug 3, 2021
1 parent f6b4ec7 commit 1465f69
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ dependencies {
// spring
api("org.springframework.boot:spring-boot-starter")
api("org.springframework.boot:spring-boot-starter-data-jpa")
api("org.springframework.retry:spring-retry")
api("info.picocli:picocli-spring-boot-starter:4.6.1")

// lsp4j core
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* This file is a part of BSL Language Server.
*
* Copyright (c) 2018-2021
* Alexey Sosnoviy <labotamy@gmail.com>, Nikita Gryzlov <nixel2007@gmail.com> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* BSL Language Server is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* BSL Language Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with BSL Language Server.
*/
package com.github._1c_syntax.bsl.languageserver.infrastructure;

import org.springframework.context.annotation.Configuration;
import org.springframework.retry.annotation.EnableRetry;

@Configuration
@EnableRetry
public class RetryConfiguration {
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.eclipse.lsp4j.Range;
import org.eclipse.lsp4j.SymbolKind;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

Expand Down Expand Up @@ -140,6 +141,7 @@ public void clearReferences(URI uri) {
* @param symbolName Имя символа, к которому происходит обращение.
* @param range Диапазон, в котором происходит обращение к символу.
*/
@Retryable(DataIntegrityViolationException.class)
public void addMethodCall(URI uri, String mdoRef, ModuleType moduleType, String symbolName, Range range) {
String symbolNameCanonical = symbolName.toLowerCase(Locale.ENGLISH);

Expand All @@ -153,15 +155,7 @@ public void addMethodCall(URI uri, String mdoRef, ModuleType moduleType, String
newSymbol.setSymbolKind(SymbolKind.Method);
newSymbol.setSymbolName(symbolNameCanonical);

try {
return symbolRepository.save(newSymbol);
} catch (DataIntegrityViolationException ignored) {
return symbolRepository.findByMdoRefAndModuleTypeAndSymbolName(
mdoRef,
moduleType,
symbolNameCanonical
).orElseThrow();
}
return symbolRepository.save(newSymbol);
});

var location = new Location();
Expand Down

0 comments on commit 1465f69

Please sign in to comment.