Bug 46768 - CustomProperties.containsKey(key)
Summary: CustomProperties.containsKey(key)
Alias: None
Product: POI
Classification: Unclassified
Component: HPSF (show other bugs)
Version: unspecified
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
: 46769 (view as bug list)
Depends on:
Reported: 2009-02-25 18:03 UTC by Daniel Treacy
Modified: 2015-03-22 12:28 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Treacy 2009-02-25 18:03:08 UTC
CustomProperties.containsKey(key) does not function for me.
Comment 1 David Fisher 2009-02-25 18:37:39 UTC
*** Bug 46769 has been marked as a duplicate of this bug. ***
Comment 2 David Fisher 2009-02-25 18:41:21 UTC
Please provide details about how this fails for you.

Which version of POI are you using?

Do you have a simple test file and/or a code fragment that shows your trouble?

Without such we cannot know how to respond.
Comment 3 Daniel Treacy 2009-02-25 22:43:38 UTC

Sorry for not providing more information. I have since worked around th potential issue that I found. The jar I am using version 3.0.2 final. 

The example code that I was trying (Not like this, but this is the same sort of thing): 

CustomProperties customProperties = documentSummaryInformation

customProperties.put("key", "value");

\* Extraction of data by a diff class, from a different event *\

if(customProperties.containsKey("key")) {

String value = (String) customProperties.get("key");										


The condition returns false resulting in the value not being extracted. 

I'm probably missing something. 

I wrote the following method as a temp work around: (I'm not a programming or java expert, dont be too harsh on me :-))

private static boolean isCustomProperty(CustomProperties customProperties,
			String property) {
		if (logger.isDebugEnabled()) {
			logger.debug("isCustomProperty(CustomProperties, String) - start");
		try {
			Set<Map.Entry<?, CustomProperty>> set = customProperties.entrySet();
			for (Map.Entry<?, CustomProperty> me : set) {
				CustomProperty cP = (CustomProperty) me.getValue();
				String key = cP.getName();
				if (key.contains(property)) {
					if (logger.isDebugEnabled()) {
								.debug("isCustomProperty(CustomProperties, String) - end");
					return true;
		} catch (Exception e) {
			logger.error("isCustomProperty(CustomProperties, String)", e);

Thanks for your assistance.
Comment 4 Rainer Klute 2009-02-25 23:47:50 UTC
Could you please try an unconditional 

Object value = customProperties.get("key");

and after doing the get() check whether the result is null (value not in properties) or not null (you retrieved the value successfully)?

If the custom properties indeed do not contain your value the question is whether your key/value pair
a) entered the custom properties successfully
b) had been deleted by your application or
c) had been deleted by a HPSF failure.

In case c) we'd need a sample program demonstrating the error. Ideally it would be in the form of a JUnit test case, but this is not required.
Comment 5 Dominik Stadler 2015-03-22 12:28:43 UTC
No response here for a long time, therefore I am resolving this as LATER for now, if you still see this problem with the latest version of POI, then please reopen this bug with more information, preferably a unit test and sample documents which allow us to reproduce the problem more easily.