Wednesday, June 16, 2010

GAE/J - Memcache namespaces and validations

In GAE/J SDK 1.3.4 the method MemcacheService.setNamespace(String ns) was deprecated. Instead of that one should use MemcacheServiceFactory.getMemcacheService(String ns).

When using the new one, the name of the namespace is validated against pattern, but this validation is not done when calling the old (deprecated) method:


String namespace = "TEST:One";

MemcacheService msOld = MemcacheServiceFactory.getMemcacheService();
// deprecation warning by compiler, but OK at runtime:
msOld.setNamespace( namespace );

// no warning by compiler, but throws exception at runtime:
MemcacheService msNew = MemcacheServiceFactory.getMemcacheService( namespace );


The exception is:

java.lang.IllegalArgumentException:
Namespace 'TEST:One' does not match pattern '[0-9A-Za-z._-]{0,100}'.


I think that this behaviour should be documented in low-level API at least.

http://groups.google.com/group/google-appengine-java/browse_thread/thread/8b5792d38bf74f28#

No comments:

Post a Comment