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
ddcf5966
Commit
ddcf5966
authored
Feb 10, 2020
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable Spring Data Neo4j's open session in view by default
Closes gh-20012
parent
14e54451
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
36 deletions
+13
-36
Neo4jDataAutoConfiguration.java
.../autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.java
+3
-14
Neo4jProperties.java
...mework/boot/autoconfigure/data/neo4j/Neo4jProperties.java
+1
-15
additional-spring-configuration-metadata.json
...es/META-INF/additional-spring-configuration-metadata.json
+3
-1
Neo4jDataAutoConfigurationTests.java
...configure/data/neo4j/Neo4jDataAutoConfigurationTests.java
+6
-6
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.java
View file @
ddcf5966
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -18,8 +18,6 @@ package org.springframework.boot.autoconfigure.data.neo4j;
...
@@ -18,8 +18,6 @@ package org.springframework.boot.autoconfigure.data.neo4j;
import
java.util.List
;
import
java.util.List
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.neo4j.ogm.session.SessionFactory
;
import
org.neo4j.ogm.session.SessionFactory
;
import
org.neo4j.ogm.session.event.EventListener
;
import
org.neo4j.ogm.session.event.EventListener
;
...
@@ -103,20 +101,11 @@ public class Neo4jDataAutoConfiguration {
...
@@ -103,20 +101,11 @@ public class Neo4jDataAutoConfiguration {
@ConditionalOnWebApplication
(
type
=
Type
.
SERVLET
)
@ConditionalOnWebApplication
(
type
=
Type
.
SERVLET
)
@ConditionalOnClass
({
WebMvcConfigurer
.
class
,
OpenSessionInViewInterceptor
.
class
})
@ConditionalOnClass
({
WebMvcConfigurer
.
class
,
OpenSessionInViewInterceptor
.
class
})
@ConditionalOnMissingBean
(
OpenSessionInViewInterceptor
.
class
)
@ConditionalOnMissingBean
(
OpenSessionInViewInterceptor
.
class
)
@ConditionalOnProperty
(
prefix
=
"spring.data.neo4j"
,
name
=
"open-in-view"
,
havingValue
=
"true"
,
@ConditionalOnProperty
(
prefix
=
"spring.data.neo4j"
,
name
=
"open-in-view"
,
havingValue
=
"true"
)
matchIfMissing
=
true
)
static
class
Neo4jWebConfiguration
{
static
class
Neo4jWebConfiguration
{
private
static
final
Log
logger
=
LogFactory
.
getLog
(
Neo4jWebConfiguration
.
class
);
@Bean
@Bean
OpenSessionInViewInterceptor
neo4jOpenSessionInViewInterceptor
(
Neo4jProperties
properties
)
{
OpenSessionInViewInterceptor
neo4jOpenSessionInViewInterceptor
()
{
if
(
properties
.
getOpenInView
()
==
null
)
{
logger
.
warn
(
"spring.data.neo4j.open-in-view is enabled by default."
+
"Therefore, database queries may be performed during view "
+
"rendering. Explicitly configure "
+
"spring.data.neo4j.open-in-view to disable this warning"
);
}
return
new
OpenSessionInViewInterceptor
();
return
new
OpenSessionInViewInterceptor
();
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jProperties.java
View file @
ddcf5966
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -67,12 +67,6 @@ public class Neo4jProperties implements ApplicationContextAware {
...
@@ -67,12 +67,6 @@ public class Neo4jProperties implements ApplicationContextAware {
*/
*/
private
AutoIndexMode
autoIndex
=
AutoIndexMode
.
NONE
;
private
AutoIndexMode
autoIndex
=
AutoIndexMode
.
NONE
;
/**
* Register OpenSessionInViewInterceptor. Binds a Neo4j Session to the thread for the
* entire processing of the request.",
*/
private
Boolean
openInView
;
/**
/**
* Whether to use Neo4j native types wherever possible.
* Whether to use Neo4j native types wherever possible.
*/
*/
...
@@ -114,14 +108,6 @@ public class Neo4jProperties implements ApplicationContextAware {
...
@@ -114,14 +108,6 @@ public class Neo4jProperties implements ApplicationContextAware {
this
.
autoIndex
=
autoIndex
;
this
.
autoIndex
=
autoIndex
;
}
}
public
Boolean
getOpenInView
()
{
return
this
.
openInView
;
}
public
void
setOpenInView
(
Boolean
openInView
)
{
this
.
openInView
=
openInView
;
}
public
boolean
isUseNativeTypes
()
{
public
boolean
isUseNativeTypes
()
{
return
this
.
useNativeTypes
;
return
this
.
useNativeTypes
;
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json
View file @
ddcf5966
...
@@ -408,7 +408,9 @@
...
@@ -408,7 +408,9 @@
},
},
{
{
"name"
:
"spring.data.neo4j.open-in-view"
,
"name"
:
"spring.data.neo4j.open-in-view"
,
"defaultValue"
:
true
"type"
:
"java.lang.Boolean"
,
"description"
:
"Register OpenSessionInViewInterceptor that binds a Neo4j Session to the thread for the entire processing of the request."
,
"defaultValue"
:
false
},
},
{
{
"name"
:
"spring.data.neo4j.repositories.enabled"
,
"name"
:
"spring.data.neo4j.repositories.enabled"
,
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfigurationTests.java
View file @
ddcf5966
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -76,7 +76,7 @@ class Neo4jDataAutoConfigurationTests {
...
@@ -76,7 +76,7 @@ class Neo4jDataAutoConfigurationTests {
assertThat
(
context
).
hasSingleBean
(
org
.
neo4j
.
ogm
.
config
.
Configuration
.
class
);
assertThat
(
context
).
hasSingleBean
(
org
.
neo4j
.
ogm
.
config
.
Configuration
.
class
);
assertThat
(
context
).
hasSingleBean
(
SessionFactory
.
class
);
assertThat
(
context
).
hasSingleBean
(
SessionFactory
.
class
);
assertThat
(
context
).
hasSingleBean
(
Neo4jTransactionManager
.
class
);
assertThat
(
context
).
hasSingleBean
(
Neo4jTransactionManager
.
class
);
assertThat
(
context
).
hasSingl
eBean
(
OpenSessionInViewInterceptor
.
class
);
assertThat
(
context
).
doesNotHav
eBean
(
OpenSessionInViewInterceptor
.
class
);
assertThat
(
context
).
doesNotHaveBean
(
BookmarkManager
.
class
);
assertThat
(
context
).
doesNotHaveBean
(
BookmarkManager
.
class
);
});
});
}
}
...
@@ -105,7 +105,7 @@ class Neo4jDataAutoConfigurationTests {
...
@@ -105,7 +105,7 @@ class Neo4jDataAutoConfigurationTests {
assertThat
(
context
).
hasSingleBean
(
SessionFactory
.
class
);
assertThat
(
context
).
hasSingleBean
(
SessionFactory
.
class
);
assertThat
(
context
.
getBean
(
SessionFactory
.
class
)).
isSameAs
(
context
.
getBean
(
"customSessionFactory"
));
assertThat
(
context
.
getBean
(
SessionFactory
.
class
)).
isSameAs
(
context
.
getBean
(
"customSessionFactory"
));
assertThat
(
context
).
hasSingleBean
(
Neo4jTransactionManager
.
class
);
assertThat
(
context
).
hasSingleBean
(
Neo4jTransactionManager
.
class
);
assertThat
(
context
).
hasSingl
eBean
(
OpenSessionInViewInterceptor
.
class
);
assertThat
(
context
).
doesNotHav
eBean
(
OpenSessionInViewInterceptor
.
class
);
});
});
}
}
...
@@ -136,9 +136,9 @@ class Neo4jDataAutoConfigurationTests {
...
@@ -136,9 +136,9 @@ class Neo4jDataAutoConfigurationTests {
}
}
@Test
@Test
void
openSessionInViewInterceptorCanBe
Dis
abled
()
{
void
openSessionInViewInterceptorCanBe
En
abled
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.data.neo4j.open-in-view:
fals
e"
)
this
.
contextRunner
.
withPropertyValues
(
"spring.data.neo4j.open-in-view:
tru
e"
)
.
run
((
context
)
->
assertThat
(
context
).
doesNotHav
eBean
(
OpenSessionInViewInterceptor
.
class
));
.
run
((
context
)
->
assertThat
(
context
).
hasSingl
eBean
(
OpenSessionInViewInterceptor
.
class
));
}
}
@Test
@Test
...
...
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