Bill commented on a change in pull request #7167: URL: https://github.com/apache/geode/pull/7167#discussion_r766255976
########## File path: geode-serialization/src/main/java/org/apache/geode/internal/serialization/filter/DelegatingObjectInputFilterFactory.java ########## @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package org.apache.geode.internal.serialization.filter; + +import static java.util.Objects.requireNonNull; + +import java.util.Set; + +import org.apache.geode.internal.serialization.filter.impl.DelegatingObjectInputFilter; +import org.apache.geode.internal.serialization.filter.impl.ObjectInputFilterApi; +import org.apache.geode.internal.serialization.filter.impl.ObjectInputFilterApiFactory; +import org.apache.geode.internal.serialization.filter.impl.ReflectionObjectInputFilterApiFactory; + +public class DelegatingObjectInputFilterFactory implements ObjectInputFilterFactory { + + private final Runnable precondition; + private final ObjectInputFilterApiFactory apiFactory; + + public DelegatingObjectInputFilterFactory(Runnable precondition) { + this(new ReflectionObjectInputFilterApiFactory(), precondition); + } + + private DelegatingObjectInputFilterFactory(ObjectInputFilterApiFactory apiFactory, + Runnable precondition) { + this.apiFactory = requireNonNull(apiFactory, "apiFactory is required"); + this.precondition = requireNonNull(precondition, "precondition is required"); + } + + @Override + public ObjectInputFilter create(SerializableObjectConfig config, Set<String> sanctionedClasses) { + if (config.getValidateSerializableObjects()) { + precondition.run(); Review comment: I understand the value of sending in the `runnable` now. Thanks for explaining. And I'm not questioning the testabilty value of coding to interfaces. What I'm proposing is moving the two constructor parameters into the `create()` signature and eliminating the fields. Unless there is some reason have what is essentially a single function call split across two (a constructor and a method) with arguments from the first call temporarily stored in fields. Reasons to have fields might include: * the need to invoke `create()` many times per constructor call * the need to define other implementations of `ObjectInputFilterFactory` that do _not_ need `precondition` or `apiFactory` But I don't see either of those things happening here. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
