Skip to content

Property support: Use static unmodifiable Maps for common defaults - #2041

Draft
matthiaso wants to merge 1 commit into
releases/26.2from
features/matthiaso/26.2/449281_improveProperySupportWithDefaultValues
Draft

Property support: Use static unmodifiable Maps for common defaults#2041
matthiaso wants to merge 1 commit into
releases/26.2from
features/matthiaso/26.2/449281_improveProperySupportWithDefaultValues

Conversation

@matthiaso

Copy link
Copy Markdown
Member

Goal: Decrease memory usage when lots of property supports are in use.

449281

@matthiaso matthiaso self-assigned this Feb 20, 2026
@matthiaso
matthiaso force-pushed the features/matthiaso/26.2/449281_improveProperySupportWithDefaultValues branch 7 times, most recently from 0828d57 to 4d8d0f1 Compare February 24, 2026 12:01
@matthiaso
matthiaso requested a review from paolobazzi February 24, 2026 18:43
Goal: Decrease memory usage when lots of property supports are in use.

449281
@paolobazzi
paolobazzi force-pushed the features/matthiaso/26.2/449281_improveProperySupportWithDefaultValues branch from 4d8d0f1 to 7a101bf Compare June 25, 2026 14:42

@paolobazzi paolobazzi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See inputs for minor improvements

public class DefaultValueMapTest {

@Test
public void testIsEmptyAndSize() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add test methods for non-covered parts:

  • Constructor using startEmpty=true
  • containsKey
  • containsValue
  • size
  • isEmpty

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

size/isEmpty is tested by testIsEmptyAndSize - additional tests necessary?

Some other tests have been added, see https://github.com/eclipse-scout/scout.rt/compare/0d91af9a3b0a0f3a3c9a0b783d3882ca68295a28..3f51b964e32eeb523113d121e626d9125254ea83

boolean additionalValuesContainsKey = m_additionalValues.containsKey(key);
if (m_defaultValues.containsKey(key)) {
if (isDefaultValue(key, value)) { // must be same, equals would not be sufficient
return additionalValuesContainsKey

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code is hard to read -> split into several methods or use if then else on separate lines and prepending a javadoc indicating which case is handled

e.g.:

  @Override
  public Object put(String key, Object value) {
    boolean additionalValuesContainsKey = m_additionalValues.containsKey(key);
    if (m_defaultValues.containsKey(key)) {
      if (isDefaultValue(key, value)) { // must be same, equals would not be sufficient
        if (additionalValuesContainsKey) {
          Object removedValue = m_additionalValues.remove(key);
          return removedValue != REMOVED_MARKER ? removedValue : null;
        } else {
          return m_defaultValues.get(key);
        }
      }
      else if (!additionalValuesContainsKey) {
        m_additionalValues.put(key, value);
        return m_defaultValues.get(key); // load previous value from default values (if any)
      }
    }
//....

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


import org.junit.Test;

public class DefaultValueMapTest {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check for missing coverage in DefaultValueMap:

  • Iterator/EntrySet.next()
  • Iterator/EntrySet.remove()
  • Iterator/EntrySet.size
  • Iterator/EntrySet.isEmpty

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matthiaso
matthiaso marked this pull request as draft August 31, 2026 04:02
@matthiaso

matthiaso commented Aug 31, 2026

Copy link
Copy Markdown
Member Author

Added cherry-pick for 27/1, see #2322

  • Apply review comments to newly created pull request
  • Close this pull request / remove branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants