Skip to content

Condition 'admin!=null' is always 'true'  #132

Description

@lukasz-cpu

https://github.com/xaecbd/KafkaCenter/blob/30e980fdae80de0be65a855786d8263e4b9ab7eb/KafkaCenter-Core/src/main/java/org/nesc/ec/bigdata/service/KafkaAdminService.java#L76

	public boolean kafkaIsHeath(String brokerAddr) {
		boolean flag = false;
		KafkaAdmins admin = null;
		try {
			Properties props = new Properties();
			props.put(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, brokerAddr);
		    admin = new KafkaAdmins(props);
			if(admin!=null) {
				flag = true;
			}
		} catch (Exception e) {
			LOGGER.warn("connect kafka error.",e);
		}finally {
			try {
				if(admin!=null) {
					admin.close();
                }
			} catch (IOException ignored) {}
		}
		return flag;

	}
if(admin!=null) {
			flag = true;
		}

Probably this conditions always evaluate to true

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions