Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
7ef9ca02
Commit
7ef9ca02
authored
Mar 17, 2021
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.4.x'
Closes gh-25718
parents
2adf3f83
758a2ee7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
JooqExceptionTranslator.java
...work/boot/autoconfigure/jooq/JooqExceptionTranslator.java
+5
-3
JooqExceptionTranslatorTests.java
...boot/autoconfigure/jooq/JooqExceptionTranslatorTests.java
+15
-1
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqExceptionTranslator.java
View file @
7ef9ca02
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
21
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -80,10 +80,12 @@ public class JooqExceptionTranslator extends DefaultExecuteListener {
private
void
handle
(
ExecuteContext
context
,
SQLExceptionTranslator
translator
,
SQLException
exception
)
{
DataAccessException
translated
=
translate
(
context
,
translator
,
exception
);
if
(
exception
.
getNextException
()
==
null
)
{
if
(
translated
!=
null
)
{
context
.
exception
(
translated
);
}
}
else
{
logger
.
error
(
"Execution of SQL statement failed."
,
translated
);
logger
.
error
(
"Execution of SQL statement failed."
,
(
translated
!=
null
)
?
translated
:
exception
);
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jooq/JooqExceptionTranslatorTests.java
View file @
7ef9ca02
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
21
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -21,6 +21,7 @@ import java.sql.SQLException;
import
org.jooq.Configuration
;
import
org.jooq.ExecuteContext
;
import
org.jooq.SQLDialect
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.params.ParameterizedTest
;
import
org.junit.jupiter.params.provider.MethodSource
;
import
org.mockito.ArgumentCaptor
;
...
...
@@ -28,8 +29,10 @@ import org.mockito.ArgumentCaptor;
import
org.springframework.jdbc.BadSqlGrammarException
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
/**
...
...
@@ -55,6 +58,17 @@ class JooqExceptionTranslatorTests {
assertThat
(
captor
.
getValue
()).
isInstanceOf
(
BadSqlGrammarException
.
class
);
}
@Test
void
whenExceptionCannotBeTranslatedThenExecuteContextExceptionIsNotCalled
()
{
ExecuteContext
context
=
mock
(
ExecuteContext
.
class
);
Configuration
configuration
=
mock
(
Configuration
.
class
);
given
(
context
.
configuration
()).
willReturn
(
configuration
);
given
(
configuration
.
dialect
()).
willReturn
(
SQLDialect
.
POSTGRES
);
given
(
context
.
sqlException
()).
willReturn
(
new
SQLException
(
null
,
null
,
123456789
));
this
.
exceptionTranslator
.
exception
(
context
);
verify
(
context
,
times
(
0
)).
exception
(
any
());
}
static
Object
[]
exceptionTranslation
()
{
return
new
Object
[]
{
new
Object
[]
{
SQLDialect
.
DERBY
,
sqlException
(
"42802"
)
},
new
Object
[]
{
SQLDialect
.
H2
,
sqlException
(
42000
)
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment