Git Product home page Git Product logo

spring-data-keyvalue's Issues

Executing query methods on repositories is not thread-safe [DATAKV-115]

Shu Yu opened DATAKV-115 and commented

I am using Spring data key value for a web application. Calls to a repository's findByXXX fail randomly, causing an exception.

I have attached the test case that can reproduce the problem.

I think that KeyValuePartTreeQuery is reusing a SpelExpression object, causing failing in SpelQueryEngine.filterMatchingRange() because the expression evaluation context in one thread can be changed by another thread


Affects: 1.0 GA (Gosling)

Attachments:

Referenced from: pull request #16

Let the configuration infrastructure for maps default a KeyValueTemplate [DATAKV-88]

Oliver Drotbohm opened DATAKV-88 and commented

Currently a bean name keyValueTemplate is required in the ApplicationContext to bootstrap Map based repositories. We could default a bean definition using the MapKeyValueAdapterFactory using the Map type configured on the @EnableMapRepositories annotation.

MapKeyValueAdapterFactory should get the setter for the Map-type removed to become immutable


No further details from DATAKV-88

ApplicationEvents with generic type argument do not get published to listener using Spring 4.2 [DATAKV-116]

Christoph Strobl opened DATAKV-116 and commented

Type reolution fails for ApplicationEvents using generic types. Using Spring 4.2 it is required to either implement ResolvableTypeProvider or extend PayloadApplicationEvent. In order to support 4.2 from a 4.1 based source we need to provide means to deal with this by providing base handling the generics.

class KeyValueEventListener <E> implements ApplicationListener<KeyValueEvent<?>> {

	private final Class<?> domainClass;

	public KeyValueEventListener() {
		Class<?> typeArgument = GenericTypeResolver.resolveTypeArgument(this.getClass(), NeoEventListener.class);
		this.domainClass = typeArgument == null ? Object.class : typeArgument;
	}

	@SuppressWarnings({ "unchecked" })
	public void onApplicationEvent(KeyValueEvent<?> event) {

		if (event instanceof BeforeDeleteEvent<?>) {
			BeforeDeleteEvent<?> beforeDeleteEvent = (BeforeDeleteEvent<?>) event;

			// inspect for matching types and ignore others
			if (domainClass.isAssignableFrom(beforeDeleteEvent.getType())) {
				onBeforeDelete((BeforeDeleteEvent <E>) event);
			}
			// other event types...

		}
	}

	protected void onBeforeDelete(BeforeDeleteEvent<E> event) {

	}
}

Affects: 1.0 GA (Gosling)

@EnableMapRepositories should allow the definition of the Map-type to be used [DATAKV-87]

Oliver Drotbohm opened DATAKV-87 and commented

Would be cool to be able to configure the Map-type used for the repository in the @EnableMapRepositories annotation like this:

@Configuration
@EnableMapRepositories(mapType = MyMap.class)
class Config { }

Issue Links:

  • DATAKV-93 Add readme and reference documentation
    ("is depended on by")

Referenced from: pull request #2, and commits bc88cb4, 7b79e1f, b16a454, 5994025

Query using a repository's findByXXX fails when a property XXX of any entry is null [DATAKV-114]

Shu Yu opened DATAKV-114 and commented

I am using spring data key value for a web application. Queries via the repository interface can fail at random time.

It seems that this failing occurs when a property of an entry is null, which happens often in a multi-thread environment as a property may not have been set yet while another thread is making a query to a repository. This is preventing me from using Spring Data Keyvalue.

The attached test can reproduce this issue. The stack trace of the exception is:

org.springframework.data.keyvalue.core.UncategorizedKeyValueException: nested exception is java.lang.NullPointerException
	at org.springframework.data.keyvalue.core.KeyValuePersistenceExceptionTranslator.translateExceptionIfPossible(KeyValuePersistenceExceptionTranslator.java:49)
	at org.springframework.data.keyvalue.core.KeyValueTemplate.resolveExceptionIfPossible(KeyValueTemplate.java:485)
	at org.springframework.data.keyvalue.core.KeyValueTemplate.execute(KeyValueTemplate.java:380)
	at org.springframework.data.keyvalue.core.KeyValueTemplate.find(KeyValueTemplate.java:391)
	at org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery.execute(KeyValuePartTreeQuery.java:88)
	at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:454)
	at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:432)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
	at com.sun.proxy.$Proxy20.findByLastname(Unknown Source)
	at my.keyvalue.MyTest.queryFailingWithEntryOfNullLastname(MyTest.java:26)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:73)
	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:73)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:224)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:83)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:68)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:163)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
Caused by: java.lang.NullPointerException
	at org.springframework.data.keyvalue.core.SpelQueryEngine.filterMatchingRange(SpelQueryEngine.java:96)
	at org.springframework.data.keyvalue.core.SpelQueryEngine.sortAndFilterMatchingRange(SpelQueryEngine.java:76)
	at org.springframework.data.keyvalue.core.SpelQueryEngine.execute(SpelQueryEngine.java:55)
	at org.springframework.data.keyvalue.core.SpelQueryEngine.execute(SpelQueryEngine.java:38)
	at org.springframework.data.keyvalue.core.QueryEngine.execute(QueryEngine.java:56)
	at org.springframework.data.keyvalue.core.AbstractKeyValueAdapter.find(AbstractKeyValueAdapter.java:66)
	at org.springframework.data.keyvalue.core.AbstractKeyValueAdapter.find(AbstractKeyValueAdapter.java:29)
	at org.springframework.data.keyvalue.core.KeyValueTemplate$7.doInKeyValue(KeyValueTemplate.java:397)
	at org.springframework.data.keyvalue.core.KeyValueTemplate$7.doInKeyValue(KeyValueTemplate.java:391)
	at org.springframework.data.keyvalue.core.KeyValueTemplate.execute(KeyValueTemplate.java:378)
	... 40 more

Affects: 1.0 GA (Gosling)

Attachments:

Referenced from: pull request #15

Backported to: 1.0.1 (Gosling SR1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.